Zum Hauptinhalt springen
LIVE
CVSS 7.3CVE-2026-137898 | A flaw was found in pam. When built with libeconf and an unconfigured vendor directory, the pam_econf configuration handler misinterprets the search path, causing it to look for configuration files in a relative directory within the current working directory. A local attacker can exploit this by placing crafted environment configuration files in a world-writable location. If an administrator executes a privileged command from that directory, the malicious vaCVSS 6.9CVE-2026-138026 | Crypto APIs MCP server packages (@cryptoapis-io/mcp-*) before 0.4.0, mcp-blockchain-events, mcp-blockchain-fees, mcp-broadcast and mcp-prepare-transactions before 0.5.0, and mcp-aml before 0.2.0 contain a missing authentication vulnerability that allows unauthenticated network attackers to invoke tools using the operator's API key. When started with Streamable HTTP transport and --api-key, the server binds 0.0.0.0 and exposes /mcp, letting attackers consumeCVSS 7.7CVE-2026-138027 | Bagel (bagel-mcp) before 2.5.5 exposes unsandboxed DuckDB SQL execution through the read-only annotated query_messages MCP tool, allowing file access and network requests. Attackers who prompt-inject the driving LLM via recorded logs or topics can invoke read_csv_auto, COPY TO, or httpfs to read and write files and perform server-side request forgery.CVSS 7.7CVE-2026-138028 | Bagel (bagel-mcp) before 2.5.5 contains an argument injection vulnerability in RsyncFilesToLocalDirectory that allows attackers to inject rsync options because only --quiet and --log-format values are rejected. Attackers who influence the LLM through prompt-injected content can trigger run_pipeline with -e/--rsh or --rsync-path options to execute commands as the Bagel server process.CVSS 5.3CVE-2026-138029 | Wazuh-MCP-Server before commit 2bbfe12 contains a server-side request forgery vulnerability in the blueteam_check_webshell tool because WebshellCheckInput.validate_url accepts DNS hostnames without resolving them. Attackers can supply URLs whose hostnames resolve or redirect to loopback, private, or link-local addresses, making curl reach internal services and cloud metadata endpoints and leak response details.CVSS 2.3CVE-2026-138030 | SylphxAI pdf-reader-mcp 2.4.1 through 3.0.14, 3.0.16, and 3.1.2 through 3.1.4 contains a server-side request forgery vulnerability in its PDF URL loader, which validates the resolved address but does not pin it for fetch(). Attackers controlling DNS for a url passed to read_pdf can return a public address at check time and an internal address at connection time to reach internal services and cloud metadata endpoints.CVSS 7.6CVE-2026-138031 | Typebot from 2.14.0 before 3.19.0 contains an authorization flaw that allows authenticated bot authors to reference another workspace's legacy webhook by saving a foreign webhookId in an HTTP request block. Attackers can have executeHttpRequestBlock return the victim's URL, headers and body client-side, or use handleSubscribeHttpRequest to overwrite the victim's webhook URL and redirect its data.CVSS 6.0CVE-2026-138032 | WhoDB from 0.88.0 before 0.132.0 contains an access control bypass in the MCP whodb_query tool, letting callers run file-writing statements without approval because the sqlguard keyword classifier omits INTO, OUTFILE and DUMPFILE. MCP clients or prompt-injected models can execute PostgreSQL lo_export or MySQL SELECT INTO OUTFILE to create files on the database host and create tables, bypassing confirmation and read-only modes.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

The Model Context Protocol in Python

Introduction Every agent needs tools, and every tool needs a way to reach the model. Building Agentic Workflows in Python built that connection by hand — a h…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
CVE & Threat-Kontext · 9 Min. Lesezeit
Quelle: dev.to
Rubrik: Sichere Programmierung




Introduction



Every agent needs tools, and every tool needs a way to reach the model. Building Agentic Workflows in Python built that connection by hand — a hand-written JSON schema, a loop that dispatches on block.name. LLM Frameworks vs. the Raw SDK in Python showed LangChain's @tool turning a plain function into that same schema via bind_tools. Both are still bespoke: the tool lives inside one process, wired to one agent, in one language.



The Model Context Protocol (MCP) solves a different problem: it standardizes the wire format between an AI application and a tool server, so the server doesn't have to be rewritten per agent, per framework, or per language. This post covers what that buys you, builds a minimal MCP server and a client that consumes it — both on the official Python SDK — and gives an honest answer to when reaching for a protocol is worth it over a direct tool call.









The Problem MCP Solves



Without a shared protocol, every pairing of agent framework and tool needs its own glue code: a LangChain @tool wrapper, a hand-rolled schema for the raw SDK, a different wrapper again for whatever framework a teammate picks next — an integration per framework, per tool. That's an M×N problem.



MCP flattens it to M+N. A server exposes tools, resources, and prompts once, over a standard JSON-RPC protocol. Any host application — Claude Code, Claude Desktop, VS Code, or your own agent — creates an MCP client that speaks that same protocol, regardless of which framework built the host. Write the server once; every MCP-aware host can use it without new integration code.



The protocol itself is intentionally boring: JSON-RPC 2.0 messages for lifecycle negotiation, tool discovery, and tool execution. Discovery (tools/list) and execution (tools/call) are the two calls that matter for this post:




// tools/list response (abbreviated)
{
"jsonrpc": "2.0", "id": 2,
"result": { "tools": [
{ "name": "get_account_balance",
"description": "Look up the balance for an account by ID",
"inputSchema": { "type": "object",
"properties": { "account_id": { "type": "string" } },
"required": ["account_id"] } }
]}
}






Two transports cover most cases: stdio (a local subprocess, one client per server — what this post uses) and Streamable HTTP (a remote server, many clients, standard bearer-token auth). Source: MCP architecture overview.









Building a Minimal MCP Server



The official Python SDK's stable line is v1.x — v2 is alpha and explicitly not recommended for production (python-sdk README), so this post pins to it:




uv add "mcp[cli]"






FastMCP turns a type-hinted, docstring-described function into a tool — no hand-written JSON Schema, matching the "two type-hinted functions" pitch of the SDK's own quickstart. The tool is a read-only account-balance lookup, deliberately keyed by ID rather than a free-text query, for reasons the next section makes concrete:




import re
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("accounts-server")

# A fixed, in-memory dataset — stands in for a real accounts service
ACCOUNTS = {"ACC-100001": 542.10, "ACC-100002": 12.50}
ACCOUNT_ID = re.compile(r"^ACC-\d{6}$")

@mcp.tool()
def get_account_balance(account_id: str) -> str:
"""Look up the balance for an account by ID.

Args:
account_id: Account ID, e.g. ACC-100001.
"""
# Validate/whitelist BEFORE using — account_id is model-provided, untrusted data
if not ACCOUNT_ID.match(account_id):
raise ValueError("Invalid account ID format")
balance = ACCOUNTS.get(account_id)
return f"Balance for {account_id}: ${balance}" if balance is not None \
else f"No account found for {account_id}"






A read-only resource — MCP's second primitive, for data the model can load into context without an action attached — is one more decorator:




@mcp.resource("docs://refund-policy")
def refund_policy() -> str:
"""Current refund policy text."""
return "Refunds are issued within 5 business days."


if __name__ == "__main__":
mcp.run(transport="stdio") # never print() here — it corrupts the JSON-RPC stream on stdio






Source for FastMCP, @mcp.tool(), and @mcp.resource(): python-sdk v1.x README and the official Build an MCP Server tutorial. The stdio logging warning is language-agnostic: print() writes to stdout by default, which is the same stream the protocol uses — log to sys.stderr or a logging library instead.









The Trust Boundary Doesn't Move



The account_id argument a tool function receives is the same untrusted, model-provided data as block.input in the raw SDK loop (post 15) or the arguments a @tool-decorated function receives from bind_tools/create_agent (post 27) — MCP standardizes the wire format, not the trust model. FastMCP does validate the shape of arguments against the schema it derives from your type hints before your function ever runs — but shape validation only confirms account_id is a string, not that it's a safe string. The regex check above still has to happen inside the function body.



Never skip that second check by trusting the type hint alone:




# UNSAFE — never do this: string-interpolating a tool argument into a query
sql = f"SELECT balance FROM accounts WHERE id = '{account_id}'" # SQL injection

# SAFE — validate/whitelist first (as get_account_balance does above), then use a fixed
# lookup or a parameterized query — never a query string built from model input






The lesson from post 15's execute_validated_tool carries over unchanged: whitelist the shape you expect, reject anything else, and never let a tool argument reach a shell command, file path, or SQL string by concatenation.









Building a Client That Consumes the Server



A client connects over the same stdio transport, discovers the tool, and calls it — no knowledge of how the server was implemented:




import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

server_params = StdioServerParameters(command="python", args=["accounts_server.py"])

async def main():
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()

tools = await session.list_tools()
print("Available:", [t.name for t in tools.tools])

result = await session.call_tool(
"get_account_balance", arguments={"account_id": "ACC-100001"})
print(result.content[0].text)

asyncio.run(main())






Source for ClientSession, StdioServerParameters, stdio_client, and session.call_tool: python-sdk v1.x docs/client.md. This is the same pattern modelcontextprotocol.io's own Build an MCP Client tutorial uses — the client doesn't care which SDK or language built the server on the other end of the transport.









Wiring MCP Into the Agent Loop from Post 15



The agent loop itself doesn't change — only where the tool list and tool execution come from. Instead of a hand-written TOOLS list and a local execute_validated_tool function, list tools from the MCP session and route tool_use blocks through session.call_tool(...):




tools_response = await session.list_tools()
anthropic_tools = [{
"name": t.name,
"description": t.description,
"input_schema": t.inputSchema, # already the JSON-Schema shape the Messages API expects
} for t in tools_response.tools]

# Inside the loop from post 15, in place of execute_validated_tool(block.name, block.input):
mcp_result = await session.call_tool(block.name, block.input)
text_result = mcp_result.content[0].text






Everything else from post 15 — the MAX_ITERATIONS cap, claude-opus-4-8 with thinking={"type": "adaptive"}, the message bookkeeping — is unchanged. Only the tool's implementation moved to a separate, reusable process, and t.inputSchema needs no manual conversion — MCP tool schemas are already the same JSON Schema shape tools= expects.









MCP vs. the Framework Tool Abstraction (Post 27)



LangChain's @tool/bind_tools/create_agent (post 27) wrap a function living in your own Python process — convenient, but the tool only exists inside that one application. MCP wraps a separate process or service behind a standard protocol, so the same accounts server above can be launched by Claude Desktop, called from Claude Code, and consumed by this post's plain client — three unrelated hosts, zero rewritten integration code (the "broad ecosystem support" modelcontextprotocol.io advertises).



The two aren't mutually exclusive: LangChain ships langchain-mcp-adapters, which converts an MCP session's tools directly into LangChain tools, so create_agent can drive them without a manual session.call_tool loop:




from langchain_mcp_adapters.tools import load_mcp_tools
from langchain.agents import create_agent

async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await load_mcp_tools(session) # MCP tools -> LangChain tools
agent = create_agent(model, tools) # same create_agent as post 27






Source: langchain-mcp-adapters README. Framework tool abstractions and MCP solve different layers of the same problem: one wires a function into a prompt; the other lets that function's server outlive any one framework.









When MCP Earns Its Weight — and When It's Overkill



Reach for MCP when the tool or data source needs to be shared across independently-built AI applications — your accounts lookup used by Claude Desktop for support staff and Claude Code for engineers and a custom internal agent — or when you're consuming someone else's server (Sentry, GitHub, a filesystem) without writing integration code per host. It's the right call when the tool is a product in its own right, not a private implementation detail of one agent.



It's ceremony when the tool has exactly one caller in one codebase: a separate process, a stdio or HTTP transport, and a protocol handshake are pure overhead next to a @tool-decorated function (post 27) or a hand-written JSON schema (post 15) that never leaves the interpreter. Build the direct version first; promote it to an MCP server only once a second, independent host actually needs to call it.









Practical Checklist




































Practice Why it matters
Start with a direct tool call (post 15/27); promote to MCP only when a second host needs it MCP's cost — a process, a transport, a protocol — buys nothing for a single caller
Validate/whitelist tool arguments inside the function body, even with type hints in place Type hints check shape, not safety — get_account_balance still checks the regex
Never f-string a tool argument into SQL, a shell command, or a file path The same rule as posts 15/27 — MCP doesn't change the trust boundary
Never print() in a stdio-transport server Corrupts the JSON-RPC stream; log to sys.stderr or a logging library instead
Pin mcp<2 (or an explicit 2.0.0bN) rather than an unpinned install v2 is alpha; an unpinned upgrade could land breaking changes mid-project
Cite a live source for every MCP class/function before shipping The SDK is under active development; a stale snippet is worse than none








Final Thoughts



MCP doesn't replace the agentic loop from post 15 or the framework tool abstractions from post 27 — it standardizes what sits behind either one: a tool server that any compliant client can discover and call, without per-host glue code. That standardization is worth real engineering cost when a tool needs to serve more than one application; for a tool with one caller, the direct approaches this series already covered remain the simpler, and correct, default.

Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Communitydiscussie & reacties

🌐 Naar de hoofdchat

Start de discussie in de Social Chat broadcaststream of dien hierboven een vakbijdrage in via het aanvulformulier.

Cyber Threat Intelligence & Forensiek

ATT&CK-Navigator · IoC-Radar & Graaf

MITRE ATT&CK Matrix Navigator
1 belegte Technik
T1190TA0001 · Initial Access
Exploit Public-Facing Application
Mitigation: M1042 Network Segmentation & WAF Rule Enforcement
Quelle: Kontext-Klassifikation des Artikeltextes · Konfidenz 86%
Scan openbaar toegankelijke diensten met OpenVAS, scherp WAF regels, verkort patch windows.
Initial Access
CTI Threat Relationship Graph
Akteure · Techniken · Beziehungen
4 Knoten · 3 Relationen
CVE / Incident Threat Actor Software MITRE ATT&CK CWE Weakness IoC
Community Rating &amp; Social Proof
⭐ Lezersbeoordeling
–
Ø / 5.0
Nog geen recensies van lezers
Was dit artikel nuttig?
0
Geef uw beoordeling
Detailbeoordeling (optioneel)
Inhoud & Kwaliteit
Bron & Geloofwaardigheid
Actualiteit
Security Briefing Gratis · 1-klik uitschrijven

Intelligence Digest gratis

Dagelijks het belangrijkste beveiligingsnieuws · kan op elk moment worden opgehaald

Verwant Story Cluster & Sources (vector AI)

6 Cluster
20 Bronnen
The Black Friday Skimmer Left Through WebRTC: How to Test Your Checkout for It
DEV Community 1 uur geleden
19 andere bronnen
Latest from TechRadar1 uur geledenExpressVPN just undercut NordVPN’s Black Friday deal – but which of these VPNs will keep your wallet safe? Latest from TechRadar2 uur geleden50+ Black Friday deals on 5-star reviewed products — we gave these our highest rating Latest from TechRadar2 uur geledenBlack Friday streaming deals are my most intense budget task of the year — but I'm ready for it AppleInsider News2 uur geledenLast call for Amazon's $599 MacBook Neo Black Friday deal Latest from TechRadar2 uur geledenBlack Friday just brought the fun and impressive MacBook Neo back to its original price, but it has a rival in the ultra-light Dell XPS The Verge3 uur geledenWe found 60-odd Black Friday deals we love for $100 or less CNET3 uur geledenYou Still Need Batteries for Your Stuff, and Black Friday Is the Time to Stock Up on All Sizes for Up to 33% Off The Verge4 uur geledenSony’s 1000XM4C headphones are a Black Friday bargain at $198 Latest from TechRadar4 uur geledenI tested 6 AI mini PCs from GMKtec, Geekom, Minisforum, and MSI for local LLMs — here's what to buy for Black Friday WIRED4 uur geledenYeti Coolers Are up to 30% Off for Black Friday (2026) WIRED5 uur geledenThe Best Black Friday Gaming Deals I’ve Found (2026) The Verge5 uur geledenMany of our favorite Blu-ray movies are over 50 percent off for Black Friday The Verge4 uur geledenRoborock, Dreame, and Eufy are cutting robovac prices in half for Black Friday Latest from TechRadar5 uur geledenThis VPN is the best choice to stop you from falling for scam websites this Black Friday – it blocked over 98% of phishing URLs Latest from TechRadar5 uur geledenStop guessing which Ninja air fryer to buy and take our Black Friday deal quiz CNET5 uur geledenWatch DirecTV’s Entertainment Package for $50 a Month for the First 2 Months Thanks to This Black Friday Deal CNET5 uur geledenTop 4 Black Friday Gaming Deals: Save Up to $40 on EA Sports FC 27 and Other Games The Verge6 uur geledenThe new iPad Mini is getting its first major discount for Black Friday CNET6 uur geledenGet 60% Off This Nanoleaf Light Therapy Face Mask During Black Friday
13 Bronnen
CVE-2026-80502 | Dell Secure Connect Gateway up to 5.36.00.00 certificate validation (WID-SEC-2026-4842)
VulDB Updates 2 uur geleden
12 andere bronnen
VulDB Updates2 uur geledenCVE-2026-80503 | Dell Secure Connect Gateway up to 5.36.00.00 log file (WID-SEC-2026-4842) VulDB Updates2 uur geledenCVE-2026-80505 | Dell Secure Connect Gateway up to 5.36.00.00 access control (WID-SEC-2026-4842) VulDB Updates2 uur geledenCVE-2026-80504 | Dell Secure Connect Gateway up to 5.36.00.00 race condition (WID-SEC-2026-4842) VulDB Updates2 uur geledenCVE-2026-80506 | Dell Secure Connect Gateway up to 5.36.00.00 hard-coded credentials (WID-SEC-2026-4842) VulDB Updates2 uur geledenCVE-2026-80507 | Dell Secure Connect Gateway up to 5.36.00.00 buffer overflow (WID-SEC-2026-4842) VulDB Updates2 uur geledenCVE-2026-80508 | Dell Secure Connect Gateway up to 5.36.00.00 improper authentication (WID-SEC-2026-4842) VulDB Updates2 uur geledenCVE-2026-80509 | Dell Secure Connect Gateway up to 5.36.00.00 Virtual injection (WID-SEC-2026-4842) VulDB Updates2 uur geledenCVE-2026-80511 | Dell Secure Connect Gateway up to 5.36.00.00 improper authentication (WID-SEC-2026-4842) VulDB Updates2 uur geledenCVE-2026-80510 | Dell Secure Connect Gateway up to 5.36.00.00 authorization (WID-SEC-2026-4842) VulDB Updates2 uur geledenCVE-2026-80512 | Dell Secure Connect Gateway up to 5.36.00.00 log file (WID-SEC-2026-4842) VulDB Updates2 uur geledenCVE-2026-81041 | Dell Secure Connect Gateway up to 5.36.00.00 certificate validation (WID-SEC-2026-4842) VulDB Updates2 uur geledenCVE-2026-81040 | Dell Secure Connect Gateway up to 5.36.00.00 path traversal (WID-SEC-2026-4842)
Soortgelijke bijdragen
🔍 Verwandte News

Auch interessante Nachrichten The Model Context Protocol in Python

Thematisch verwandte Begriffe: Model, Context, Protocol, Python · 6 Treffer

Laden...

Video's zijn geladen...

Laden...

Bijdragen zijn geladen ...

Laden...

Video's zijn geladen...

Laden...

Bijdragen zijn geladen ...

Laden...

Video's zijn geladen...

Laden...

Bijdragen zijn geladen ...

Laden...

Video's zijn geladen...

Laden...

Bijdragen zijn geladen ...

Laden...

Video's zijn geladen...

💬 Reacties worden geladen…
Trek om te vernieuwen
Widgets & Topics
Loading widgets…
Nächster Beitrag