Skip to main content

solvemcp - a small, pragmatic Model Context Protocol (MCP) client.

Project description

solvemcp

It provides:

  • stdio transport for local subprocess servers.
  • Streamable HTTP transport for modern MCP servers.
  • Legacy HTTP+SSE fallback for older servers.
  • Dynamic Python callables for tools returned by tools/list.

Installation

pip install solvemcp

Quick Start

Connect to a local stdio server

from solvemcp import MCPClient
with MCPClient.stdio([sys.executable, "-u", "../tests/echoserver.py"]) as mcp:
    print(list(mcp.tools))
    res = mcp.echo(text="hello")
    print(res)
['echo']
{'content': [{'type': 'text', 'text': 'hello'}]}

Connect to an HTTP MCP server

with MCPClient.http("https://mcp.grep.app") as mcp:
    print(list(mcp.tools))
    res = mcp.searchGitHub(query="class PtyProcess", language=["Python"])
['searchGitHub']
cts = res['content']
print(len(cts))
10
print(cts[0]['text'][:500])
Repository: sedwards2009/extraterm
Path: extensions/ProxySessionBackend/src/python/ptyprocess/ptyprocess.py
URL: https://github.com/sedwards2009/extraterm/blob/master/extensions/ProxySessionBackend/src/python/ptyprocess/ptyprocess.py
License: MIT

Snippets:
--- Snippet 1 (Line 79) ---
            (intr, eof) = (3, 4)
    
    _INTR = _byte(intr)
    _EOF = _byte(eof)

class PtyProcessError(Exception):
    """Generic error class for this package."""

# setecho and setwinsize are pulled out here b

How Tool Calls Work

For each server tool with a valid Python identifier name, MCPClient adds a method dynamically. Example: a server tool named echo becomes mcp.echo(...).

Equivalent forms:

mcp.echo(text="hi")
mcp.call_tool("echo", text="hi")

Streaming

For Streamable HTTP servers, use rpc_stream or call_tool_stream:

for msg in mcp.rpc_stream("tools/list", params={}): print(msg)

Module Layout

  • solvemcp/client.py: MCPClient request lifecycle, initialization, tool binding, and RPC helpers.
  • solvemcp/transports.py: transport implementations plus SSE parsers and error types.

Development

Run tests:

python tests/tests.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solvemcp-0.0.1.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

solvemcp-0.0.1-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file solvemcp-0.0.1.tar.gz.

File metadata

  • Download URL: solvemcp-0.0.1.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for solvemcp-0.0.1.tar.gz
Algorithm Hash digest
SHA256 82ce2687b4d0ff9ce0e8e63463d347e83677352a82dcb3888fe07586f3b374d4
MD5 5e749f575d60fc798c1e0fb15f1289fa
BLAKE2b-256 624b3b38ee8c3d9cd59c9f6f0620318f5e745eb323eaeb947a509d9db6b2c0cc

See more details on using hashes here.

File details

Details for the file solvemcp-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: solvemcp-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for solvemcp-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5d2ad9ede54da6d3774a59e2358c4ccd023a283c3e8a20f321d2963305204c25
MD5 6b96784062fecb9521f6ca6a05fec598
BLAKE2b-256 2993094a579c8b8bc7c4260e7cb2078c75213f88097e4ad6ca91b9c29c789b6b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page