# mcp-tool-server-v3

> mcp-tool-server-v3: 15 Keryn rules for typescript, javascript, python, json (1 error, 12 warning, 2 info).

Source: https://keryn.dev/rules/mcp-tool-server-v3/

15 rules · Keryn Software Licence · rules 0.8.0 · [all packs](https://keryn.dev/rules/)

**How to read a rule**

- **Severity**: How bad the finding is if it is real: `error` fails a default gate, `warning` and `info` do not.

- **Confidence**: **P0** exploitable as written; **P1** dangerous in context; **P2** a heuristic or a posture check: confirm by reading the code.

- **False-positive risk**: **low**: an exact API or flag, so hits are almost always real; **medium**: the pattern is legitimate in many programs, so check each hit; **high**: it finds a lead to confirm, so expect benign hits.

- **Edge**: The relationship the finding sits on. **reaches**: content or traffic gets to a thing; **calls**: one thing invokes another; **reads**: one thing reads from another; **writes**: one thing writes to another; **sends**: data leaves for another party; **grants**: authority is given or left unchecked; **depends_on**: something relies on a component it does not verify; **trusts**: one party believes another without evidence. The boundary it crosses, when there is one: **user->prompt** (untrusted input reaching a prompt); **model->code** (model output reaching code, a shell, a query or a page); **secret->outside** (a secret leaving the trusted side); **supply-chain** (code, models or prompts pulled in from outside).

- **Taxonomy chips**: References for readers who work in OWASP LLM 2025, OWASP Agentic, CWE or NIST AI RMF. They say where a rule belongs, not that a framework is satisfied.

## seceng.mcp.v3.tool-shell-command-from-args

`warning` typescript, javascript mcp

MCP tool handler executes shell command from tool arguments without visible allowlist or approval.

Confidence **P2**: a heuristic or a posture check: confirm by reading the code. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [calls](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another; it crosses the [`model->code`](https://keryn.dev/docs/edges/trust-boundaries/#model-to-code) boundary (model output reaching code, a shell, a query or a page).

[CWE-78](https://keryn.dev/taxonomies/cwe/#cwe-78-os-command-injection) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI05](https://keryn.dev/taxonomies/owasp-agentic/#asi05-unexpected-code-execution) [ASI01](https://keryn.dev/taxonomies/owasp-agentic/#asi01-agent-goal-hijack) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation)

**Try it: a snippet that triggers this rule**

Written for this page, not taken from any project. Save it as `src/server.mjs` and scan it with `keryn scan src --verbose`; the finding below appears.

```js
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { exec as execCb } from "node:child_process";
import { promisify } from "node:util";
import { z } from "zod";

const exec = promisify(execCb);
const server = new McpServer({ name: "build-helper", version: "0.3.0" });

server.tool(
  "run_task",
  { command: z.string().describe("Task to run in the workspace") },
  async (args) => {
    const { stdout, stderr } = await exec(args.command, { cwd: "/workspace" });
    return { content: [{ type: "text", text: stdout || stderr }] };
  }
);
```

Checked with Keryn's browser engine when this page was built: it reports `seceng.mcp.v3.tool-shell-command-from-args` at line 13 (warning, proof 1). The rule's own logic is not published, so it cannot run in this tab; the pack list in the [playground](https://keryn.dev/playground/) shows what does.

## seceng.mcp.v3.tool-file-read-from-args

`warning` typescript, javascript mcp

MCP tool handler reads file path from tool arguments without visible sandbox or path validation.

Confidence **P2**: a heuristic or a posture check: confirm by reading the code. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [reads](https://keryn.dev/docs/edges/edge-kinds/#reads) one thing reads from another.

[CWE-22](https://keryn.dev/taxonomies/cwe/#cwe-22-path-traversal) [CWE-200](https://keryn.dev/taxonomies/cwe/#cwe-200-exposure-of-sensitive-information-to-an-unauthorized-actor) [LLM02](https://keryn.dev/taxonomies/owasp-llm/#llm02-sensitive-information-disclosure) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI10](https://keryn.dev/taxonomies/owasp-agentic/#asi10-rogue-agents)

**Try it: a snippet that triggers this rule**

Written for this page, not taken from any project. Save it as `src/server.mjs` and scan it with `keryn scan src --verbose`; the finding below appears.

```js
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { readFile } from "node:fs/promises";
import { z } from "zod";

const server = new McpServer({ name: "notes", version: "1.0.0" });

server.tool(
  "read_note",
  { path: z.string() },
  async (args) => {
    const text = await readFile(args.path, "utf8");
    return { content: [{ type: "text", text }] };
  }
);
```

Checked with Keryn's browser engine when this page was built: it reports `seceng.mcp.v3.tool-file-read-from-args` at line 11 (warning, proof 1). The rule's own logic is not published, so it cannot run in this tab; the pack list in the [playground](https://keryn.dev/playground/) shows what does.

## seceng.mcp.v3.tool-file-write-from-args

`warning` typescript, javascript mcp

MCP tool handler writes file path from tool arguments without visible sandbox, approval, or path validation.

Confidence **P2**: a heuristic or a posture check: confirm by reading the code. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [writes](https://keryn.dev/docs/edges/edge-kinds/#writes) one thing writes to another.

[CWE-22](https://keryn.dev/taxonomies/cwe/#cwe-22-path-traversal) [CWE-73](https://keryn.dev/taxonomies/cwe/#cwe-73-external-control-of-file-name-or-path) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI10](https://keryn.dev/taxonomies/owasp-agentic/#asi10-rogue-agents)

**Try it: a snippet that triggers this rule**

Written for this page, not taken from any project. Save it as `src/server.mjs` and scan it with `keryn scan src --verbose`; the finding below appears.

```js
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { writeFile } from "node:fs/promises";
import { z } from "zod";

const server = new McpServer({ name: "notes", version: "1.0.0" });

server.tool(
  "save_note",
  { path: z.string(), body: z.string() },
  async (args) => {
    await writeFile(args.path, args.body);
    return { content: [{ type: "text", text: "saved" }] };
  }
);
```

Checked with Keryn's browser engine when this page was built: it reports `seceng.mcp.v3.tool-file-write-from-args` at line 11 (warning, proof 1). The rule's own logic is not published, so it cannot run in this tab; the pack list in the [playground](https://keryn.dev/playground/) shows what does.

## seceng.mcp.v3.tool-url-fetch-from-args

`warning` typescript, javascript mcp

MCP tool handler fetches URL from tool arguments without visible allowlist validation. This can enable SSRF or data exfiltration.

Confidence **P2**: a heuristic or a posture check: confirm by reading the code. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [reaches](https://keryn.dev/docs/edges/edge-kinds/#reaches) content or traffic gets to a thing; it crosses the [`user->prompt`](https://keryn.dev/docs/edges/trust-boundaries/#user-to-prompt) boundary (untrusted input reaching a prompt).

[CWE-918](https://keryn.dev/taxonomies/cwe/#cwe-918-server-side-request-forgery) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation)

**Try it: a snippet that triggers this rule**

Written for this page, not taken from any project. Save it as `src/server.mjs` and scan it with `keryn scan src --verbose`; the finding below appears.

```js
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";

const server = new McpServer({ name: "web-reader", version: "0.2.1" });

server.tool(
  "get_page",
  { url: z.string().url() },
  async (args) => {
    const res = await fetch(args.url, { headers: { accept: "text/html" } });
    const html = await res.text();
    return { content: [{ type: "text", text: html.slice(0, 20000) }] };
  }
);
```

Checked with Keryn's browser engine when this page was built: it reports `seceng.mcp.v3.tool-url-fetch-from-args` at line 10 (warning, proof 1). The rule's own logic is not published, so it cannot run in this tab; the pack list in the [playground](https://keryn.dev/playground/) shows what does.

## seceng.mcp.v3.tool-returns-env

`warning` typescript, javascript, python mcp

MCP tool returns environment variables or secret-looking values to caller.

Confidence **P2**: a heuristic or a posture check: confirm by reading the code. False-positive risk **low**: an exact API or flag, so hits are almost always real.

Edge inspected: [reaches](https://keryn.dev/docs/edges/edge-kinds/#reaches) content or traffic gets to a thing; it crosses the [`user->prompt`](https://keryn.dev/docs/edges/trust-boundaries/#user-to-prompt) boundary (untrusted input reaching a prompt).

[CWE-200](https://keryn.dev/taxonomies/cwe/#cwe-200-exposure-of-sensitive-information-to-an-unauthorized-actor) [CWE-798](https://keryn.dev/taxonomies/cwe/#cwe-798-use-of-hard-coded-credentials) [LLM02](https://keryn.dev/taxonomies/owasp-llm/#llm02-sensitive-information-disclosure) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation)

## seceng.mcp.v3.tool-returns-secret-py

`warning` python mcp

MCP tool returns environment variables or secret-looking values to caller.

Confidence **P2**: a heuristic or a posture check: confirm by reading the code. False-positive risk **low**: an exact API or flag, so hits are almost always real.

Edge inspected: [reaches](https://keryn.dev/docs/edges/edge-kinds/#reaches) content or traffic gets to a thing; it crosses the [`user->prompt`](https://keryn.dev/docs/edges/trust-boundaries/#user-to-prompt) boundary (untrusted input reaching a prompt).

[CWE-200](https://keryn.dev/taxonomies/cwe/#cwe-200-exposure-of-sensitive-information-to-an-unauthorized-actor) [CWE-798](https://keryn.dev/taxonomies/cwe/#cwe-798-use-of-hard-coded-credentials) [LLM02](https://keryn.dev/taxonomies/owasp-llm/#llm02-sensitive-information-disclosure) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation)

## seceng.mcp.v3.public-server-bind-no-auth

`warning` python mcp

MCP server binds to public interface without visible auth or token verification.

Confidence **P2**: a heuristic or a posture check: confirm by reading the code. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [grants](https://keryn.dev/docs/edges/edge-kinds/#grants) authority is given or left unchecked.

[CWE-306](https://keryn.dev/taxonomies/cwe/#cwe-306-missing-authentication-for-critical-function) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [LLM07](https://keryn.dev/taxonomies/owasp-llm/#llm07-system-prompt-leakage) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI10](https://keryn.dev/taxonomies/owasp-agentic/#asi10-rogue-agents)

**Try it: a snippet that triggers this rule**

Written for this page, not taken from any project. Save it as `server.py` and scan it with `keryn scan server.py --verbose`; the finding below appears.

```python
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("inventory")

@mcp.tool()
def stock_level(sku: str) -> int:
    """Return the units on hand for a SKU."""
    return {"A-100": 14, "B-200": 3}.get(sku, 0)

if __name__ == "__main__":
    mcp.run(transport="sse", host="0.0.0.0", port=8000)
```

Checked with Keryn's browser engine when this page was built: it reports `seceng.mcp.v3.public-server-bind-no-auth` at line 13 (warning, proof 0). The rule's own logic is not published, so it cannot run in this tab; the pack list in the [playground](https://keryn.dev/playground/) shows what does.

## seceng.mcp.v3.public-server-bind-no-auth-js

`warning` javascript, typescript mcp

MCP server binds to public interface without visible auth or token verification.

Confidence **P2**: a heuristic or a posture check: confirm by reading the code. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [grants](https://keryn.dev/docs/edges/edge-kinds/#grants) authority is given or left unchecked.

[CWE-306](https://keryn.dev/taxonomies/cwe/#cwe-306-missing-authentication-for-critical-function) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [LLM07](https://keryn.dev/taxonomies/owasp-llm/#llm07-system-prompt-leakage) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI10](https://keryn.dev/taxonomies/owasp-agentic/#asi10-rogue-agents)

**Try it: a snippet that triggers this rule**

Written for this page, not taken from any project. Save it as `src/index.mjs` and scan it with `keryn scan src --verbose`; the finding below appears.

```js
import express from "express";

const app = express();
app.use(express.json());

app.post("/mcp", async (req, res) => {
  res.json({ jsonrpc: "2.0", id: req.body.id, result: {} });
});

app.listen(3000, "0.0.0.0", () => {
  console.log("mcp server listening on 3000");
});
```

Checked with Keryn's browser engine when this page was built: it reports `seceng.mcp.v3.public-server-bind-no-auth-js` at line 10 (warning, proof 0). The rule's own logic is not published, so it cannot run in this tab; the pack list in the [playground](https://keryn.dev/playground/) shows what does.

## seceng.mcp.v3.tool-schema-additional-properties

`info` python, json mcp

MCP tool schema allows arbitrary additional properties or lacks strict argument validation.

Confidence **P2**: a heuristic or a posture check: confirm by reading the code. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [calls](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another.

[CWE-20](https://keryn.dev/taxonomies/cwe/#cwe-20-improper-input-validation) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI01](https://keryn.dev/taxonomies/owasp-agentic/#asi01-agent-goal-hijack) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation)

## seceng.mcp.v3.tool-schema-additional-properties-js

`info` javascript, typescript mcp

MCP tool schema allows arbitrary additional properties or lacks strict argument validation.

Confidence **P2**: a heuristic or a posture check: confirm by reading the code. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [reads](https://keryn.dev/docs/edges/edge-kinds/#reads) one thing reads from another.

[CWE-20](https://keryn.dev/taxonomies/cwe/#cwe-20-improper-input-validation) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI01](https://keryn.dev/taxonomies/owasp-agentic/#asi01-agent-goal-hijack) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation)

## seceng.mcp.v3-browser-tool-no-domain-allowlist

`warning` typescript, javascript, python mcp

MCP/browser tool navigates to URL from tool arguments without visible domain allowlist.

Confidence **P2**: a heuristic or a posture check: confirm by reading the code. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [grants](https://keryn.dev/docs/edges/edge-kinds/#grants) authority is given or left unchecked.

[CWE-918](https://keryn.dev/taxonomies/cwe/#cwe-918-server-side-request-forgery) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation)

## seceng.mcp.v3.tool-file-read-from-args-py

`warning` python data-flow rule mcp, fastmcp, python

A Python MCP server tool (FastMCP @&lt;server&gt;.tool) opens a path taken from its arguments without confining it to a base directory or the client roots. The model chooses tool arguments, so a prompt-injected call can read any file the server can (CWE-22).

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [reads](https://keryn.dev/docs/edges/edge-kinds/#reads) one thing reads from another.

[CWE-22](https://keryn.dev/taxonomies/cwe/#cwe-22-path-traversal) [CWE-200](https://keryn.dev/taxonomies/cwe/#cwe-200-exposure-of-sensitive-information-to-an-unauthorized-actor) [LLM02](https://keryn.dev/taxonomies/owasp-llm/#llm02-sensitive-information-disclosure) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI10](https://keryn.dev/taxonomies/owasp-agentic/#asi10-rogue-agents)

**Fix:** Resolve the path against a fixed base directory (or a root from ctx.session.list\_roots()) and refuse it unless resolved.is\_relative\_to(base); never pass the raw argument to open() or Path().

**References:** [https://github.com/modelcontextprotocol/python-sdk](https://github.com/modelcontextprotocol/python-sdk) · [https://gofastmcp.com/servers/tools](https://gofastmcp.com/servers/tools)

## seceng.mcp.v3.tool-file-write-from-args-py

`warning` python data-flow rule mcp, fastmcp, python

A Python MCP server tool (FastMCP @&lt;server&gt;.tool) writes or deletes a path taken from its arguments without confining it to a base directory or the client roots. A prompt-injected call can overwrite or remove any file the server can (CWE-22, CWE-73).

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [writes](https://keryn.dev/docs/edges/edge-kinds/#writes) one thing writes to another.

[CWE-22](https://keryn.dev/taxonomies/cwe/#cwe-22-path-traversal) [CWE-73](https://keryn.dev/taxonomies/cwe/#cwe-73-external-control-of-file-name-or-path) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI10](https://keryn.dev/taxonomies/owasp-agentic/#asi10-rogue-agents)

**Fix:** Resolve the path against a fixed base directory (or a root from ctx.session.list\_roots()), refuse it unless resolved.is\_relative\_to(base), and ask for approval before destructive writes.

**References:** [https://github.com/modelcontextprotocol/python-sdk](https://github.com/modelcontextprotocol/python-sdk) · [https://gofastmcp.com/servers/tools](https://gofastmcp.com/servers/tools)

## seceng.mcp.v3.tool-shell-command-from-args-py

`error` python data-flow rule mcp, fastmcp, python

A Python MCP server tool (FastMCP @&lt;server&gt;.tool) runs a shell command or code built from its arguments. The model chooses tool arguments, so a prompt-injected call runs commands on the server host (CWE-78).

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [calls](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another; it crosses the [`model->code`](https://keryn.dev/docs/edges/trust-boundaries/#model-to-code) boundary (model output reaching code, a shell, a query or a page).

[CWE-78](https://keryn.dev/taxonomies/cwe/#cwe-78-os-command-injection) [CWE-94](https://keryn.dev/taxonomies/cwe/#cwe-94-code-injection) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling) [ASI05](https://keryn.dev/taxonomies/owasp-agentic/#asi05-unexpected-code-execution) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation)

**Fix:** Map the argument to a fixed command from an allow-list (Literal or Enum parameter), pass an argv list with shell=False, and require approval for anything with side effects.

**References:** [https://github.com/modelcontextprotocol/python-sdk](https://github.com/modelcontextprotocol/python-sdk) · [https://gofastmcp.com/servers/tools](https://gofastmcp.com/servers/tools)

## seceng.mcp.v3.tool-url-fetch-from-args-py

`warning` python data-flow rule mcp, fastmcp, python

A Python MCP server tool (FastMCP @&lt;server&gt;.tool) fetches a URL taken from its arguments without a host allow-list. A prompt-injected call can reach internal services or cloud metadata and exfiltrate data (CWE-918).

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [reaches](https://keryn.dev/docs/edges/edge-kinds/#reaches) content or traffic gets to a thing; it crosses the [`user->prompt`](https://keryn.dev/docs/edges/trust-boundaries/#user-to-prompt) boundary (untrusted input reaching a prompt).

[CWE-918](https://keryn.dev/taxonomies/cwe/#cwe-918-server-side-request-forgery) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation)

**Fix:** Parse the URL, require https and a host from a fixed allow-list, and refuse private, loopback and link-local addresses after DNS resolution.

**References:** [https://github.com/modelcontextprotocol/python-sdk](https://github.com/modelcontextprotocol/python-sdk) · [https://gofastmcp.com/servers/tools](https://gofastmcp.com/servers/tools)
