Metadata-Version: 2.4
Name: mcp_static_toolgen
Version: 0.1.2
Summary: Static binding code generator for MCP tools
Author-email: hyranno <hyranno4pub@gmail.com>
License: https://opensource.org/license/mit
        
        Copyright 2026 hyranno and contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
License-File: LICENSE
Keywords: code-generation,llm-tools,mcp,model-context-protocol,pydantic,tool-generation
Requires-Python: >=3.14
Requires-Dist: black>=26.3.0
Requires-Dist: jinja2>=3.1.6
Requires-Dist: langchain-mcp-adapters>=0.2.1
Requires-Dist: langchain>=1.2.12
Requires-Dist: mcp>=1.26.0
Requires-Dist: pydantic>=2.12.5
Requires-Dist: typing>=3.10.0.0
Description-Content-Type: text/markdown

# MCP-Static-Toolgen

Static binding code generator for MCP tools.

## Background

Most MCP integrations fetch tool schemas **dynamically at runtime**. While flexible, this makes it impossible to use static type checkers, breaks IDE autocompletion, and introduces "runtime surprises" when upstream schemas change.

This project is a **static bindgen** for MCP. It connects to an MCP server once and generates strictly typed Python code. By moving tool resolution from **runtime to build-time**, you get:

* **Full Type Safety**: Catch interface mismatches with `mypy` or `pyright` before execution.

* **IDE Support**: Enjoy perfect autocompletion for tool arguments.

* **Determinism**: Your agent's interface is locked in code, making it auditable and production-ready.

## Usage
#### Install
```
uv add mcp_static_toolgen
```

#### Code Generation
```python
import asyncio
from langchain_mcp_adapters.sessions import Connection
from mcp_static_toolgen.mcp import connect_and_generate

connections: dict[str, Connection] = {
    "mock": {
        "transport": "stdio",
        "command": "python",
        "args": ["src/tests/mock_mcp_server.py"],
    },
}
generated_codes = asyncio.run(connect_and_generate(connections))
```
See `example` for complete example.
