generic-mcp-client-chat

Generic MCP Client to use any MCP tool in a chat

rom1504communicationPythonMIT
0Tools
17Findings
44Stars
Downloads
Mar 22, 2026Last Scanned

Findings17

4critical
10high
2medium
1low
0informational
criticalC1Command InjectionMCP03-command-injectionAML.T0054
Pattern "`[^`]+`" matched in source_code: "`json\s*(\{[\s\S]*?\})\s*`" (at position 8716)
Replace exec()/execSync() with execFile() and pass arguments as an array, never as a string. Validate all inputs against an allowlist before use in any shell context. For subprocess.run, always pass a list and shell=False.
criticalQ13MCP Bridge Package Supply Chain AttackMCP10-supply-chainAML.T0054
Pattern "(?:mcp|fastmcp|langchain-mcp|llama-index-mcp)(?:>=|~=|==)?(?!\d)" matched in source_code: "mcp" (at position 333)
MCP bridge packages (mcp-remote, mcp-proxy, @modelcontextprotocol/sdk, fastmcp) are high-value supply chain targets — CVE-2025-6514 (CVSS 9.6) in mcp-remote affected 437,000+ installs. Always pin exact versions (no ^ or ~ ranges). Use lockfiles (package-lock.json, pnpm-lock.yaml, uv.lock). Never run `npx mcp-remote` without version pinning. Verify package integrity with `npm audit` or `pip-audit` before deployment. Reference: CVE-2025-6514, OWASP ASI04.
criticalN9MCP Logging Protocol InjectionMCP01-prompt-injectionAML.T0054
Pattern "(?:logger|logging)\s*\.\s*(?:info|warning|error|debug)\s*\(\s*(?:f"|f').*(?:result|output|response|tool_output|content)" matched in source_code: "logger.info(f"Availability check for {url} got status: {response" (at position 3646)
Sanitize all dynamic content before including in MCP log messages. MCP logging notifications (notifications/message) are displayed in client UIs — injection payloads in log data can influence AI behavior if the client processes logs as context. Strip control characters, ANSI escape codes, newlines, and prompt injection patterns from log content. Use structured logging with separate data fields.
criticalL7Transitive MCP Server DelegationMCP06-excessive-permissionsAML.T0054
Pattern "(?:connect|initialize).*(?:mcp|modelcontextprotocol).*(?:server|endpoint|url)" matched in source_code: "connect to default MCP server '{default_server_name}' at {default_mcp_server_url" (at position 1115)
MCP servers MUST NOT create client connections to other MCP servers without explicit user disclosure. If delegation is required, declare all downstream servers in the server's capabilities and tool descriptions. Never forward user credentials to sub-servers. Implement a trust boundary between the approved server and any delegated servers. Log all transitive delegations for audit.
highD1Known CVEs in DependenciesMCP08-dependency-vuln
Dependency "aiohttp@3.9.3" has known CVEs:
Update dependencies to versions that patch known CVEs. Run 'npm audit fix' or 'pip-audit' to identify and resolve vulnerable dependencies.
highD1Known CVEs in DependenciesMCP08-dependency-vuln
Dependency "fastmcp@2.0.0" has known CVEs:
Update dependencies to versions that patch known CVEs. Run 'npm audit fix' or 'pip-audit' to identify and resolve vulnerable dependencies.
highD1Known CVEs in DependenciesMCP08-dependency-vuln
Dependency "requests@2.31.0" has known CVEs:
Update dependencies to versions that patch known CVEs. Run 'npm audit fix' or 'pip-audit' to identify and resolve vulnerable dependencies.
highK11Missing Server Integrity VerificationMCP10-supply-chainAML.T0054
Pattern "(connect|load|register|add)[_\s-]?(mcp|server|tool)(?!.*(?:verify|validate|checksum|hash|sign|cert|fingerprint|pin))" matched in source_code: "connect_mcp" (at position 4248)
Implement cryptographic verification for MCP server connections: (1) Pin server TLS certificates or public keys, (2) Verify server tool definition checksums against a known-good manifest, (3) Use package manager integrity checks (npm integrity, pip --require-hashes). The MCP spec recommends but doesn't yet mandate server signing — implement it proactively. Required by ISO 27001 A.8.24 and CoSAI MCP-T6.
highK16Unbounded Recursion / Missing Depth LimitsMCP07-insecure-configAML.T0054
Pattern "(invoke|call|execute)[_\s-]?(?:tool|agent|self)(?!.*(?:depth|level|limit|max[_\s-]?(?:depth|recursi|iter|call)|count))" matched in source_code: "call_tool" (at position 9634)
Add explicit depth/recursion limits to all recursive operations. Use iterative approaches where possible. Set maximum depth for directory walking (max_depth=10), tree traversal (max_level=20), and agent re-invocation (max_calls=5). Implement circuit breakers that halt after N iterations. Required by EU AI Act Art. 15 (robustness) and OWASP ASI08.
highQ14Concurrent MCP Server Race ConditionMCP07-insecure-configT1068
Pattern "(?:read|write|modify|delete).*(?:file|path|directory)(?!.*(?:lock|mutex|semaphore|flock|atomic))" matched in source_code: "ready include the /mcp path" (at position 4629)
MCP servers sharing filesystem or database backends with other servers must implement proper concurrency controls. Use: (1) file locking (flock/lockfile) for filesystem operations, (2) database transactions for all read-modify-write sequences, (3) atomic file operations (O_EXCL, mkdtemp) instead of check-then-create, (4) lstat() to detect symlinks before following (CVE-2025-53109). Never assume exclusive access to shared resources — other MCP servers may be operating concurrently.
highC3Server-Side Request Forgery (SSRF)MCP04-data-exfiltrationAML.T0057
Pattern "session\.(?:get|post|put|delete|patch|request)\s*\([^)]*(?:req|request|input|param|params|args|url|uri|href|target|endpoint|host)" matched in source_code: "session.get(url" (at position 3502)
Validate ALL user-supplied URLs before making HTTP requests: 1. Parse the URL and check the hostname against an explicit allowlist of permitted domains. 2. Block requests to RFC 1918 private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16. 3. Block loopback (127.0.0.0/8), link-local (169.254.0.0/16), and IPv6 equivalents. 4. Block file:// and other non-http(s) protocols explicitly. 5. Disable automatic redirect following, or re-validate each redirect destination. 6. In cloud environments: block requests to IMDS endpoints (169.254.169.254, metadata.google.internal) at both the application AND network layer. Example (Node.js): Use the `ssrf-req-filter` package or implement URL validation against an allowlist before calling fetch/axios/got.
highD1Known CVEs in DependenciesMCP08-dependency-vuln
Dependency "starlette@0.40.0" has known CVEs:
Update dependencies to versions that patch known CVEs. Run 'npm audit fix' or 'pip-audit' to identify and resolve vulnerable dependencies.
highD1Known CVEs in DependenciesMCP08-dependency-vuln
Dependency "mcp@1.8.0" has known CVEs:
Update dependencies to versions that patch known CVEs. Run 'npm audit fix' or 'pip-audit' to identify and resolve vulnerable dependencies.
highO8Timing-Based Covert ChannelMCP04-data-exfiltrationAML.T0057
Pattern "(?:delay|sleep|timeout|interval)\s*[:=]\s*(?:[^;]*(?:secret|token|password|credential|key|env))" matched in source_code: "timeout=3) as response: # We just care if it responds, status 200-4xx is fine for a basic ping logger.info(f"Availability check for {url} got status: {response.status}") return True # Server is at least responding to HTTP except asyncio.TimeoutError: logger.error(f"Timeout during basic availability check for {url}") return False except aiohttp.ClientConnectorError as e: logger.error(f"Connection error during basic availability check for {url}: {e}") return False except Exception as e: logger.error(f"Unexpected error during basic availability check for {url}: {e}") return False @app.post("/api/connect") async def connect_mcp_server(request: ConnectionRequest): logger.info(f"API call to connect to MCP server: '{request.server_name}' at {request.server_url}") if not request.server_url.startswith(("http://", "https://")): raise HTTPException(status_code=400, detail="Invalid server_url format. Must include http:// or https://") # The server_url for connect should already include the /mcp path if needed by FastMCP server if await check_server_availability(request.server_url): logger.info(f"Basic availability check passed for '{request.server_name}'. Proceeding with FastMCP connection.") success = await mcp_manager.connect(request.server_name, request.server_url) if success: logger.info(f"Successfully initiated connection to '{request.server_name}'.") return {"status": "connected", "server_name": request.server_name} else: logger.error(f"Failed to connect to '{request.server_name}' using MCPManager after availability check.") raise HTTPException(status_code=500, detail=f"Failed to connect to MCP server '{request.server_name}'. Check server logs.") else: logger.error(f"Basic availability check failed for '{request.server_name}' at {request.server_url}.") raise HTTPException(status_code=503, detail=f"MCP server '{request.server_name}' not available at {request.server_url}.") @app.post("/api/disconnect") async def disconnect_mcp_server(request: DisconnectRequest): logger.info(f"API call to disconnect from MCP server: '{request.server_name}'") success = await mcp_manager.disconnect(request.server_name) if success: logger.info(f"Successfully processed disconnect for '{request.server_name}'.") return {"status": "disconnected", "server_name": request.server_name} else: # Disconnect might return False if error during cleanup, but still considered processed. logger.warning(f"Disconnect for '{request.server_name}' completed, possibly with minor issues (e.g., already disconnected).") return {"status": "disconnected_with_issues_or_not_found", "server_name": request.server_name} @app.post("/api/chat") async def chat(request: Request): try: data = await request.json() message = data.get("message", "") # Get response from Claude with all available tools all_tools = [] for server_name in mcp_manager._clients.keys(): if mcp_manager.is_connected(server_name): try: tools = await mcp_manager.list_tools(server_name) logger.info(f"Found {len(tools)} tools on server {server_name}") for tool in tools: tool_info = { "name": f"{server_name}.{tool.name}", # Prefix tool name with server "description": tool.description, "input_schema": tool.inputSchema, "server": server_name } logger.info(f"Adding tool: {tool_info['name']}") all_tools.append(tool_info) except Exception as e: logger.error(f"Error getting tools from server {server_name}: {e}") logger.info(f"Total tools available: {len(all_tools)}") # Create system message with tool descriptions system_content = f"""You are a helpful AI assistant with access to the following tools: {json.dumps(all_tools, indent=2)} When you need to use a tool, respond with a JSON object in this format: {{ "tool": "server_name.tool_name", "parameters": {{ "param_name": "param_value" }} }} For example, to use the echo tool, respond with: {{ "tool": "default_mcp.echo", "parameters": {{ "message": "your message here" }} }} Otherwise, respond normally with your message.""" # Get response from Claude response = anthropic.messages.create( model="claude-3-7-sonnet-20250219", max_tokens=1024, system=system_content, messages=[{"role": "user", "content": message}] ) # Check if response is a tool call try: response_text = response.content[0].text.strip() # Try to extract JSON from code block code_block_match = re.search(r'```json\s*(\{[\s\S]*?\})\s*```', response_text) if code_block_match: json_str = code_block_match.group(1) tool_call = json.loads(json_str) else: # Try to find the first JSON object in the text json_match = re.search(r'(\{[\s\S]*\})', response_text) if json_match: tool_call = json.loads(json_match.group(1)) else: tool_call = json.loads(response_text) if isinstance(tool_call, dict) and "tool" in tool_call and "parameters" in tool_call: # Parse server and tool name server_name, tool_name = tool_call["tool"].split(".", 1) logger.info(f"Executing tool call: {tool_name} on server {server_name}") # Execute the tool call tool_response = await mcp_manager.call_tool( server_name, tool_name, tool_call["parameters"] ) return {"response": str(tool_response)} except Exception as e: logger.error(f"Tool call parsing/execution failed: {e}") # Not a tool call, return Claude's response pass return {"response": response.content[0].text} except Exception as e: logger.error(f"Error in chat endpoint: {e}") raise HTTPException(status_code=500, detail=str(e)) @app.get("/api/servers") async def list_servers(): """List all connected servers""" connected_servers = [] for server_name in mcp_manager._clients.key" (at position 3519)
Remove all code that calculates sleep/delay durations from application data, secrets, or any variable-length content. Tool response times should be constant or determined only by legitimate processing time. If rate limiting is needed, use fixed intervals not derived from data values. Monitor for anomalous response time patterns that could indicate timing-based exfiltration.
mediumK17Missing Timeout or Circuit BreakerMCP07-insecure-configAML.T0054
Pattern "(?:fetch|axios|got|request|urllib|httpx|http\.get|http\.post)\s*\((?!.*(?:timeout|signal|AbortSignal|deadline|cancel))" matched in source_code: "Request(" (at position 2942)
Add timeouts to ALL external calls: HTTP requests (30s), database queries (10s), subprocess execution (60s), and MCP tool calls (30s). Implement circuit breakers that open after N consecutive failures (e.g., opossum, cockatiel). Use AbortSignal for cancellable operations. Required by EU AI Act Art. 15 and OWASP ASI08.
mediumK20Insufficient Audit Context in LoggingMCP09-logging-monitoringAML.T0054
Pattern "logger\.(info|warn|error)\s*\(.*(?:tool|request|handle|invoke)(?!.*(?:requestId|correlationId|traceId|spanId|agent[_\s-]?id|user[_\s-]?id))" matched in source_code: "logger.info(f"Tools on '{default_server_name}': {tool" (at position 1780)
Use structured logging that includes all five ISO 27001 A.8.15 fields: (1) WHO — agent/user identity, (2) WHAT — tool name and operation, (3) WHEN — ISO 8601 timestamp, (4) WHERE — server ID and correlation ID, (5) OUTCOME — success/failure and result summary. Replace console.log with structured loggers (pino, winston). Add correlation IDs for request tracing across multi-agent chains.
lowF4MCP Spec Non-ComplianceMCP07-insecure-config
Server fails MCP spec compliance checks: required:server_name; required:server_version; required:protocol_version; recommended:tool_descriptions; recommended:parameter_descriptions
Follow the MCP specification for server metadata. Include server name, version, and protocol version. Provide descriptions for all tools and parameters.

Tools

No tools exposed by this server.

Security Category Deep Dive

Sub-Category Tree · Remediation Roadmap · Attack Stories · Compliance Overlay · ATLAS Techniques · Maturity Model

Prompt Injection
Prompt & context manipulation attacks
69
Maturity
14
Rules
5
Sub-Categories
1
Gaps
64%
Implemented
56
Tests
1
Stories
PI-DIRDirect Input Injection
100%3 rules
Injection via tool descriptions and parameter fields
GAP-001Prompt Injection Coverage GapMissing detection coverage for emerging prompt injection attack variants not addressed by current rules
PI-INDIndirect / Gateway Injection
100%4 rules
Hidden instructions via external content and tool responses
PI-CTXContext Manipulation
100%2 rules
Context window saturation and prior-approval exploitation
PI-ENCEncoding & Obfuscation
100%3 rules
Payload hiding via invisible chars, base64, schema fields
PI-TPLTemplate & Output Poisoning
100%2 rules
Injection via prompt templates and runtime tool output
Framework Coverage
OWASP MCP Top 1014/14
MITRE ATLAS14/14
CoSAI MCP2/14
OWASP Agentic Top 1012/14
Kill Chain Phases
0Initial Access
0Defense Evasion
0Execution
0Persistence