Skip to main content

mcp-tool

English | 中文


mcp-tool is a small toolkit for building Model Context Protocol (MCP) servers in Python.

It provides a decorator-based tool registry, a JSON-RPC 2.0 handler, and WebSocket / stdio transports so you can expose your tools to MCP-compatible clients.

Features

  • JSON-RPC 2.0 handling with initialize, tools/list, and tools/call
  • Async @tool decorator for registering MCP tools
  • In-memory registry and /doc endpoint to list available tools
  • WebSocket transport built with FastAPI (/ws, /healthz, /doc)
  • stdio transport for local integrations over stdin/stdout
  • Typer-based CLI to run your MCP server in service or stdio mode

Installation

For local development:

python -m venv .venv
source .venv/bin/activate
pip install -e .

OR

pip install mcp-tool-tingz

Defining tools

Use the @tool decorator exported from the package:

from mcp_tool import tool

@tool(description="Simple ping tool to verify MCP connectivity")
async def ping(message: str = "pong") -> str:
    return f"MCP: {message}"

You can see a more complete example in mcp-tool/demo_app.py.

Running the server

The CLI exposes a single run command with two modes: service (WebSocket) and stdio.

WebSocket service mode

Start an MCP server over WebSocket:

mcp-tool run --mode service --host 0.0.0.0 --port 8765 --app mcp_tool.demo_app
  • --app points to a Python module or file that registers tools (via @tool).
  • The server exposes:
    • GET /healthz — health check
    • GET /doc — tools documentation (from the registry plus server metadata)
    • WS /ws — JSON-RPC 2.0 over WebSocket

You can point an MCP-compatible client at ws://localhost:8765/ws.

stdio mode

To run the same tools over stdio (useful for editor or local CLI integrations):

mcp-tool run --mode stdio --app mcp_tool.demo_app

The process reads and writes JSON-RPC messages framed with Content-Length headers on stdin/stdout.

JSON-RPC protocol

mcp-tool follows JSON-RPC 2.0 and implements:

  • initialize — returns server metadata and capabilities
  • tools/list (and tools.list) — lists all registered tools and their schemas
  • tools/call (and tools.call) — calls a registered tool with arguments

A typical successful response looks like:

{"jsonrpc": "2.0", "id": "uuid", "result": {...}}

An error response looks like:

{"jsonrpc": "2.0", "id": "uuid", "error": {"code": -32603, "message": "Internal error"}}

License

This project is licensed under the MIT License. See LICENSE for details.

Metadata

Release files for mcp-tool-tingz 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-tool-tingz 0.1.3
File Size Uploaded Provenance
mcp_tool_tingz-0.1.3.tar.gz 10.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-tool-tingz 0.1.3
File Interpreter ABI Platform
mcp_tool_tingz-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 24.2 kB

Release files / mcp_tool_tingz-0.1.3.tar.gz

Download URL mcp_tool_tingz-0.1.3.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d7b12c023825b9601e648fff3bcc3df077e92e9b9da10b051f471f169d6171fa
BLAKE2b-256 checksum
How to use checksums
ef24b55b5990f03c79894afb78c5826f525c6546b8fd6dda3f63b94a9ce6ed11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / mcp_tool_tingz-0.1.3-py3-none-any.whl

Download URL mcp_tool_tingz-0.1.3-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31fcf560b6f54ea62aa664b04bc6e223e9cacd568150c3e0f24d17e9f02f74d5
BLAKE2b-256 checksum
How to use checksums
7c93d931ab0fe513ae2c02a0e98be2879412dca7eee4bb284bd13e10226547e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for mcp-tool-tingz 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page