twat-mcp: Model Context Protocol plugin for twat
Part of the twat collection of tools.
twat-mcp adds Model Context Protocol (MCP) support to the twat ecosystem, letting AI assistants (Claude Code, Cursor, etc.) discover and call tools exposed through MCP servers.
What is MCP?
The Model Context Protocol is Anthropic's open standard for connecting AI models to external tools and data sources. It defines a client–server architecture:
- MCP server: exposes a set of callable tools (functions, resources, prompts)
- MCP client / host: an AI assistant or IDE that discovers those tools and invokes them on the model's behalf
twat-mcp turns twat into an MCP host. It loads tool servers, handles session negotiation, and routes tool calls between AI clients and the underlying implementations.
Installation
Requires Python 3.10+. Install with uv (recommended) or pip:
uv pip install twat-mcp
# or
pip install twat-mcp
The twat package must also be installed.
How it works
twat-mcp registers itself as a twat plugin via a Python entry point:
[project.entry-points."twat.plugins"]
mcp = "twat_mcp:TwatMcpPlugin"
When twat starts, it calls importlib.metadata.entry_points(group="twat.plugins"), loads TwatMcpPlugin, and delegates MCP lifecycle management to this plugin. The plugin:
- Reads MCP server configuration (stdio commands, SSE endpoints, or in-process SDK servers)
- Negotiates capabilities with each server using the MCP handshake
- Exposes discovered tools to connected AI clients
- Routes tool call requests and returns results
Architecture
AI client (Claude Code, Cursor, …)
│ MCP protocol (JSON-RPC over stdio/SSE/HTTP)
▼
TwatMcpPlugin ←─ loaded by twat via entry_points
│
├── mcp_search.py (tool discovery and query)
└── MCP server connections (stdio / SSE / SDK)
Key components
| File | Purpose |
|---|---|
src/twat_mcp/__init__.py |
TwatMcpPlugin class; plugin entry point |
src/twat_mcp/mcp_search.py |
Discovers and queries MCP tool servers |
src/twat_mcp/__version__.py |
Version string (managed by hatch-vcs) |
Development
git clone https://github.com/twardoch/twat-mcp.git
cd twat-mcp
uv pip install hatch
hatch shell
pre-commit install
# Lint / format / type-check
hatch run lint-all
# Tests
hatch run test:test-cov
Versioning uses git tags via hatch-vcs. Create an annotated tag and push to trigger a GitHub Actions release.
License
MIT. Contributions welcome under the same license.
Metadata
Release files for twat-mcp 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| twat_mcp-1.0.3.tar.gz | 57.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| twat_mcp-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 62.5 kB
Release files / twat_mcp-1.0.3.tar.gz
| Download URL | twat_mcp-1.0.3.tar.gz |
|---|---|
| Size | 57.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db302cc1c9f7a1dc197a053650f7c2bc01e7fc4928cfaa3a61fcd520e9be9818
|
|
BLAKE2b-256 checksum How to use checksums |
ec84974befa3bc95643d20aa2575daf88b3cfeb1031e93639e2400cfac6a1af2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / twat_mcp-1.0.3-py3-none-any.whl
| Download URL | twat_mcp-1.0.3-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d521edf4826c01562deea7c4aa2fa17d85424d0212bf8d6767de429c889229f4
|
|
BLAKE2b-256 checksum How to use checksums |
5c2aed2ebf114bdf9a36e9dec21ade0131f0e79f29245dd25ac5ea912c2e7594
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for twat-mcp 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.