Skip to main content

Audit and compile Python tool schemas for LLM agents.

Project description

mcp-toolsmith

Audit and compile Python tool schemas for LLM agents.

Pre-1.0: JSON tool files are safe by default. Python files require --execute and should only be used with trusted code. The public API may change before 1.0.0.

mcp-toolsmith is a small Python-first CLI and library for checking whether tool metadata is usable by LLM agents, then compiling those tools into MCP or OpenAI-style tool definitions.

It helps catch problems such as vague tool names, missing descriptions, oversized schemas, overlapping tools, and prompt-injection-like language inside tool metadata.

Install

pip install mcp-toolsmith

For local development:

python -m pip install -e ".[dev]"

Usage

Audit JSON tool definitions

JSON tool definitions are safe by default:

mcp-toolsmith audit tools.json

Example JSON input:

{
  "tools": [
    {
      "name": "search_docs",
      "description": "Search project documentation by natural language query.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string",
            "description": "Question or topic to search for."
          },
          "limit": {
            "type": "integer",
            "description": "Maximum number of results to return.",
            "default": 5
          }
        },
        "required": ["query"]
      }
    }
  ]
}

Example audit output:

OK Audited 1 tool(s) from tools.json
Errors: 0  Warnings: 0

search_docs [mcp] ~55 schema tokens
  No findings

Compile tools

Compile to MCP-style tool definitions:

mcp-toolsmith compile tools.json --target mcp

Compile to OpenAI-style function definitions:

mcp-toolsmith compile tools.json --target openai

Audit trusted Python files

Python files are executable source code, so mcp-toolsmith refuses to import them unless you opt in:

mcp-toolsmith audit tools.py --execute
mcp-toolsmith compile tools.py --target mcp --execute

Use --execute only for trusted files.

By default, Python discovery only includes functions decorated with @tool:

from mcp_toolsmith import tool


@tool
def search_docs(query: str, limit: int = 5) -> list[str]:
    """Search project documentation by natural language query.

    Args:
        query: Question or topic to search for.
        limit: Maximum number of results to return.
    """
    return []

Use decorator arguments to override the generated tool name or description:

from mcp_toolsmith import tool


@tool(
    name="search_project_docs",
    description="Search project docs and return matching document IDs.",
)
def search_docs(query: str, limit: int = 5) -> list[str]:
    """Search project documentation by natural language query."""
    return []

Use --all-public to include every public top-level function and Pydantic model:

mcp-toolsmith audit tools.py --execute --all-public
mcp-toolsmith compile tools.py --target mcp --execute --all-public

--all-public is mainly a compatibility path for early alpha behavior. For new Python tool files, prefer @tool.

Python API

from mcp_toolsmith import audit_file, compile_file

report = audit_file("tools.json")
report.print()

mcp_tools = compile_file("tools.json", target="mcp")
openai_tools = compile_file("tools.json", target="openai")

For trusted Python files:

report = audit_file("tools.py", execute=True)
mcp_tools = compile_file("tools.py", target="mcp", execute=True)

To opt into broad Python discovery:

report = audit_file("tools.py", execute=True, all_public=True)
mcp_tools = compile_file("tools.py", target="mcp", execute=True, all_public=True)

Checks

Check Why it matters
Vague tool names Agents may pick the wrong tool when names are generic
Missing descriptions Tool selection depends heavily on clear descriptions
Missing argument descriptions Models need argument-level context
Oversized schemas Large schemas cost tokens and can distract smaller models
Overlapping tools Similar tools make tool choice unstable
Tool-poisoning language Tool metadata is part of the prompt surface

Roadmap

Version Goal
0.2.0 Decorator-based Python tool discovery
0.3.0 OpenAPI input and richer JSON Schema validation
0.4.0 Provider compatibility profiles for Anthropic, Gemini, and OpenAI
0.5.0 Deterministic schema compaction and rewriting
1.0.0 Stable public API and compatibility matrix

License

MIT

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

mcp_toolsmith-0.2.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

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

mcp_toolsmith-0.2.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file mcp_toolsmith-0.2.0.tar.gz.

File metadata

  • Download URL: mcp_toolsmith-0.2.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mcp_toolsmith-0.2.0.tar.gz
Algorithm Hash digest
SHA256 600711cac69d5711489d66fe213dd5144abcc8d4c6eac3f75cdc534360fc28c0
MD5 381b116278d5cb4a245f7107de8d7d13
BLAKE2b-256 2d7bf70d016dae8c38e7657a37a7cf7a130cd9a2434548df9c17e81fbefeb1d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_toolsmith-0.2.0.tar.gz:

Publisher: release.yml on ShAmoNiA/mcp-toolsmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_toolsmith-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_toolsmith-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mcp_toolsmith-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d38efeda52538a5e4b3876a88e1ade9e8afbd73182cb04bc2e425267a0a19de
MD5 4121cfda301977cdccee6adea866a567
BLAKE2b-256 85aa024b9df7f717c566870de3623c091659d843db1691fedb45f6d0cb9a9343

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_toolsmith-0.2.0-py3-none-any.whl:

Publisher: release.yml on ShAmoNiA/mcp-toolsmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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