Metadata-Version: 2.4
Name: solvemcp
Version: 0.0.1
Summary: solvemcp - a small, pragmatic Model Context Protocol (MCP) client.
Author: Jeremy Howard
License: Apache-2.0
Project-URL: Homepage, https://github.com/AnswerDotAI/solvemcp
Project-URL: Repository, https://github.com/AnswerDotAI/solvemcp
Project-URL: Documentation, https://AnswerDotAI.github.io/solvemcp/
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastcore
Requires-Dist: httpx
Provides-Extra: dev
Requires-Dist: fastship; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# solvemcp


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

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

``` bash
pip install solvemcp
```

## Quick Start

### Connect to a local stdio server

``` python
from solvemcp import MCPClient
```

``` python
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

``` python
with MCPClient.http("https://mcp.grep.app") as mcp:
    print(list(mcp.tools))
    res = mcp.searchGitHub(query="class PtyProcess", language=["Python"])
```

    ['searchGitHub']

``` python
cts = res['content']
print(len(cts))
```

    10

``` python
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:

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

## Streaming

For Streamable HTTP servers, use `rpc_stream` or `call_tool_stream`:

``` python
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:

``` bash
python tests/tests.py
```
