MCP Auto Register
This package automates the registration of functions and classes from a python package into a FastMCP instance.
Installation
To install the package, run the following command:
pip install mcp-auto-register
Usage
Register functions from a package:
from mcp_auto_register.register import register_functions_from_package
from mcp.server.fastmcp import FastMCP
# Initialize MCP instance
mcp_instance = FastMCP()
register_functions_from_package('scipy.linalg', mcp_instance=mcp_instance, func_filter=['eigh', 'inv'])
if __name__ == "__main__":
mcp_instance.run()
Register classes from a package:
import inspect
from mcp_auto_register.register import register_classes_from_package
from mcp.server.fastmcp import FastMCP
from nba_api.stats.endpoints._base import Endpoint
# Create MCP instance
mcp = FastMCP()
def nba_endpoint_wrapper(endpoint: Endpoint):
init_params = inspect.signature(endpoint.__init__).parameters
required_args = {
p: param.annotation if param.annotation != inspect.Parameter.empty else "Any"
for p, param in init_params.items()
if p != "self" and param.default == inspect.Parameter.empty
}
def wrapper(**kwargs):
return endpoint(**kwargs).get_dict()
wrapper.__signature__ = inspect.Signature(
parameters=[
inspect.Parameter(arg, inspect.Parameter.POSITIONAL_OR_KEYWORD)
for arg, _ in required_args.items()
]
)
return wrapper
register_classes_from_package("nba_api.stats.endpoints", nba_endpoint_wrapper, mcp)
if __name__ == "__main__":
mcp.run(transport="stdio")
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mcp_auto_register-1.0.2.tar.gz
(35.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_auto_register-1.0.2.tar.gz.
File metadata
- Download URL: mcp_auto_register-1.0.2.tar.gz
- Upload date:
- Size: 35.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cc45e26560e065af7ba3d80cf459f9d7b7bb823f7905a5c2686cf4a0787d7ea
|
|
| MD5 |
47483ed35d8329c5bf71adf0b28fdf24
|
|
| BLAKE2b-256 |
ffb414872023ced8b0dbbedb2705d4560731577bc806b64eaefa69d437c82434
|
File details
Details for the file mcp_auto_register-1.0.2-py3-none-any.whl.
File metadata
- Download URL: mcp_auto_register-1.0.2-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81533a7e0209209691f0f0fcbd28f7048c36f0900797a587d4a2e84329dc8fe1
|
|
| MD5 |
3799f8d60a194154b7dd6aa1133d169b
|
|
| BLAKE2b-256 |
b9f730f2320d090fe3976a87f0e0126b6308ec2f71e577e27edafe31275144e1
|