Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Talk to a remote MCP server with only the Python standard library (and call two tools without a key)

Most "connect your agent to MCP" guides start with installing an SDK and a client. But the protocol underneath a remote MCP server is just JSON-RPC over HTTPS POST. If you want to know what a server actually does before you wire it into Claude, Cursor or VS Code, you can talk to it with the Python standard library in about 60 lines. This post does exactly that against a real server,…

The article demonstrates how to interact with a remote MCP server using only Python's standard library, without requiring any additional packages or API keys. By leveraging JSON-RPC over HTTPS POST, the author shows how to connect to a real server at https://siftwright.com/mcp.

The author explains that communicating with the MCP server involves three key JSON-RPC methods: initialize, which establishes protocol version and server name; tools/list, which retrieves tool details; and tools/call, which runs a specified tool with provided arguments.

The article provides a concise Python script that showcases these concepts. It begins by importing necessary modules, setting the MCP_URL and an optional API_KEY for authenticated calls. The rpc function handles sending JSON-RPC requests, managing the request ID, and parsing responses. If an API key is provided, it's included in the request headers.

To demonstrate the functionality, the script performs three actions:

1. Calls initialize to confirm protocol version and obtain the server's title and supported protocol version.

2. Calls tools/list to retrieve a list of available tools, including domain_whois and pqc_scan, which can be used without an API key.

3. Calls domain_whois with a sample domain to retrieve WHOIS information without exceeding the daily limit.

The output of these three calls is then printed, providing a clear example of interacting with the MCP server using only the Python standard library.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

More from Thursday 26 November →