Cover image

Generieren Sie automatisch pydantische Modelle für alle Funktionen in einem Python -Paket.

3 years

Works with Finder

1

Github Watches

0

Github Forks

1

Github Stars

🐶 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.

相关推荐

  • av
  • Führen Sie mühelos LLM -Backends, APIs, Frontends und Dienste mit einem Befehl aus.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 llm 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Zusammenfassung der weltbesten LLM -Ressourcen.

  • 1Panel-dev
  • 🔥 1Panel bietet eine intuitive Weboberfläche und einen MCP -Server, um Websites, Dateien, Container, Datenbanken und LLMs auf einem Linux -Server zu verwalten.

  • rulego
  • ⛓️Rugele ist ein leichter, leistungsstarker, leistungsstarker, eingebetteter Komponenten-Orchestrierungsregel-Motor-Rahmen für GO.

  • hkr04
  • Leichtes C ++ MCP (Modellkontextprotokoll) SDK

  • sigoden
  • Erstellen Sie einfach LLM -Tools und -Argarten mit einfachen Bash/JavaScript/Python -Funktionen.

  • RockChinQ
  • 😎简单易用、🧩丰富生态 - 大模型原生即时通信机器人平台 | 适配 qq / 微信(企业微信、个人微信) / 飞书 / 钉钉 / diskord / telegram / slack 等平台 | 支持 Chatgpt 、 Deepseek 、 Diffy 、 Claude 、 Gemini 、 xai 、 ppio 、 、 ulama 、 lm Studio 、阿里云百炼、火山方舟、 siliconflow 、 qwen 、 mondshot 、 chatglm 、 sillytraven 、 mcp 等 llm 的机器人 / agent | LLM-basierte Instant Messaging Bots-Plattform, unterstützt Zwietracht, Telegramm, Wechat, Lark, Dingtalk, QQ, Slack

  • modelscope
  • Bauen Sie LLM-Multi-Agent-Anwendungen auf einfachere Weise auf.

  • dmayboroda
  • On-Premise-Konversationslappen mit konfigurierbaren Behältern

  • evilsocket
  • Das einfache Agentenentwicklungskit.

    Reviews

    2.1 (14)
    Avatar
    user_aYj95KtS
    2025-04-26

    I've been using mcpup by lmmx and it has truly revolutionized my workflow. The ease of use and streamline functionality makes it stand out. The support and welcoming message right from the start made the integration seamless. Highly recommend it for anyone looking to enhance their productivity.

    Avatar
    user_bpUjtacs
    2025-04-26

    As a dedicated user of mcpup, I must say it has greatly simplified my workflow! mcpup, created by the brilliant lmmx, offers a seamless and efficient experience that caters to all my programming needs. Whether you are a beginner or an expert, this tool is designed to enhance productivity with its user-friendly interface and powerful capabilities. Highly recommended for anyone in the tech community!

    Avatar
    user_BICmdlYi
    2025-04-26

    I have been using mcpup by lmmx for a while now, and it has truly impressed me. The user interface is sleek and intuitive, making navigation a breeze. It's evident that a lot of thought went into the design and functionality of this application. Highly recommended for anyone looking for a reliable solution!

    Avatar
    user_aJBv4GaL
    2025-04-26

    MCPup is a game-changer for project management enthusiasts! Created by lmmx, it offers seamless navigation and intuitive interface, making it effortless to stay on top of tasks and collaborations. Highly recommended for professionals seeking efficiency.

    Avatar
    user_5lH3JClV
    2025-04-26

    I am absolutely thrilled with mcpup by lmmx! This application has been incredibly useful and user-friendly. The interface is sleek and intuitive, making it easy to navigate. It has significantly improved my productivity. Highly recommend this app to anyone looking to streamline their workflow!

    Avatar
    user_6sl230zx
    2025-04-26

    As an avid user of the mcpup application created by lmmx, I am genuinely impressed by its efficiency and user-friendly interface. The seamless integration and intuitive design make navigation a breeze, significantly improving my workflow. Highly recommend it to anyone looking to enhance their productivity!

    Avatar
    user_a3s5ndk2
    2025-04-26

    As a dedicated user of the mcpup application developed by lmmx, I can attest to its exceptional utility and user-friendly design. It seamlessly integrates with my workflow, enhancing productivity and efficiency. Highly recommended for anyone looking to optimize their digital tasks!

    Avatar
    user_T3muIyTB
    2025-04-26

    I've been using mcpup for a while now, and I must say it's truly impressive. Developed by lmmx, it's a well-thought-out tool that has significantly boosted my productivity. The interface is intuitive, and it seamlessly integrates with other applications. Highly recommend it to anyone looking to streamline their workflow!

    Avatar
    user_fXtlUj8n
    2025-04-26

    As a dedicated user of mcpup, I can confidently say this tool is a game-changer. The seamless integration and user-friendly interface make it incredibly efficient for all my requirements. Kudos to lmmx for creating such an excellent product. Highly recommend it!

    Avatar
    user_GRpmye1w
    2025-04-26

    MCPUP by lmmx is an impressive application that has significantly enhanced my productivity. The intuitive design and user-friendly interface make it easy to navigate and leverage its powerful features right from the starting URL. The welcoming information is helpful and sets a positive tone. Highly recommended for anyone looking to streamline their workflow!

    Avatar
    user_qONE5LIX
    2025-04-26

    As a regular user of mcpup, I can confidently say it’s a fantastic tool. Developed by lmmx, it provides seamless functionality and user-friendly features. It’s evident that a lot of thought and care went into designing this application. Highly recommend it to anyone in need of a reliable program!

    Avatar
    user_PYyQq85S
    2025-04-26

    As an avid user of MCP applications, I find "mcpup" by lmmx to be an excellent tool that seamlessly integrates with my workflow. Its user-friendly interface and robust features make it a standout product. Highly recommend it to anyone in need of a reliable MCP solution!

    Avatar
    user_S7ZetkIJ
    2025-04-26

    I've been using mcpup by lmmx, and it has exceeded my expectations! The user interface is intuitive, making navigation a breeze. The welcome messages are friendly and engaging. Overall, mcpup is a reliable and user-friendly application that I would highly recommend.

    Avatar
    user_7s3uX6zO
    2025-04-26

    As a loyal user of MCP applications, I must say MCPUP by lmmx stands out remarkably. Its seamless integration and intuitive design truly elevate the user experience. Highly recommended for anyone seeking reliable and efficient performance.