Skip to main content

🐶 mcpup

uv pdm-managed PyPI Supported Python versions License

Automatically generate Pydantic models for all functions in a Python package.

Features

  • Automatic Function Discovery: Scans all modules in a package to find functions
  • Pydantic Model Generation: Creates Pydantic models for function parameters using pydantic-function-models
  • Validation: Generated models perform validation according to type hints
  • Package Structure Preservation: Maintains the original package's module structure
  • Optional uv Integration: Can install packages on-the-fly with uv

Installation

# Install with pip
pip install mcpup

# Or with uv
uv pip install mcpup

Requirements

  • Python 3.10+
  • uv (recommended)

Command Line Usage

Generate Pydantic models for all functions in a package:

mcpup package_name

Options:

--output, -o DIRECTORY       Directory to save generated models [default: ./mcpup_models]
--install, -i                Install the package using uv before generating models
--include-private            Include private functions (starting with underscore)
--module, -m TEXT            Specific modules to include (can be used multiple times)
--help                       Show help message and exit

Examples

Generate models for all functions in the polars package:

mcpup polars

Generate models only for specific modules:

mcpup polars --module dataframe --module series

Install the package first, then generate models:

mcpup some-package --install

Include private functions:

mcpup mypackage --include-private

Programmatic Usage

You can also use mcpup programmatically:

from mcpup.scanner import scan_package
from mcpup.generator import generate_models
from pathlib import Path

# Scan a package for functions
functions = scan_package("mypackage", include_private=False)

# Generate models
output_path = Path("./models")
generate_models(functions, output_path)

Using Generated Models

After generating models, you can use them to validate function arguments:

# Import the generated model
from mcpup_models.mypackage.mymodule import MyFunction

# Validate function arguments
valid_args = MyFunction.model.model_validate({
    "arg1": "value",
    "arg2": 123
})

# Call the function with validated arguments
from mypackage.mymodule import my_function
result = my_function(**valid_args.model_dump(exclude_unset=True))

MCP Integration

mcpup can be used to generate JSON schemas from Python packages, making it perfect for integration with Model Context Protocol (MCP) servers. MCP servers provide a standardized way for AI models to discover and use tools without custom integrations for each service.

Using mcpup with MCP Servers

Generate Pydantic models with mcpup, then access the JSON schemas to create MCP-compatible tools:

>>> from mcpup_models.requests import api
>>> from pprint import pprint
>>> api.Get.model
<class 'pydantic_function_models.validated_function.Get'>
>>> pprint(api.Get.model.model_json_schema())
{'properties': {'args': {'default': None,
                         'items': {},
                         'title': 'Args',
                         'type': 'array'},
                'kwargs': {'default': None,
                           'title': 'Kwargs',
                           'type': 'object'},
                'params': {'default': None, 'title': 'Params'},
                'url': {'title': 'Url'},
                'v__duplicate_kwargs': {'default': None,
                                        'items': {'type': 'string'},
                                        'title': 'V  Duplicate Kwargs',
                                        'type': 'array'}},
 'required': ['url'],
 'title': 'Get',
 'type': 'object'}

How This Powers MCP Servers

MCP servers use JSON schemas to:

  1. Define Tool Capabilities: Each function in a package becomes a tool with a well-defined schema
  2. Enable Natural AI Interaction: AI can understand the schema and use tools correctly
  3. Support Mode Switching: Use with execution for actual API calls, or schema-only for documentation

You can turn any Python package into a composition of MCP-compatible tools, allowing AI systems to:

  • Discover available functions
  • Understand parameter requirements
  • Validate inputs before execution
  • Generate proper API calls

This approach makes Python packages accessible to AI systems in a standardized way, without requiring custom integration work for each package.

Contributing

Contributions welcome!

  1. Issues & Discussions: Please open a GitHub issue or discussion for bugs, feature requests, or questions.
  2. Pull Requests: PRs are welcome!
    • Install the dev extra with pip install -e ".[dev]"
    • Run tests with pytest
    • Include updates to docs or examples if relevant

License

This project is licensed under the MIT License.

Release files for mcpup 0.1.2

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

Source distribution (sdist)

Source distribution for mcpup 0.1.2
File Size Uploaded
mcpup-0.1.2.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mcpup 0.1.2
File Interpreter ABI Platform
mcpup-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / mcpup-0.1.2.tar.gz

Download URL mcpup-0.1.2.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ffa678181f63e40cb0b84ddc9fb51a3e50e62139d836d20f116102cdb3ef325f
BLAKE2b-256 checksum
How to use checksums
9096c352fa9b6fae62b001deb18f12b6af8e0be33213e889338711c01a32d7f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release files / mcpup-0.1.2-py3-none-any.whl

Download URL mcpup-0.1.2-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4077cb046649efe4114d9724bd844c64390effb004be249d6b85c9eb61ee93e9
BLAKE2b-256 checksum
How to use checksums
267c64d0c9e189f4ff0e23a0467027fd12eb3eaeb5236e2e3af27cedb669d7fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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