basesmcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@basesmcpturn my Python function into an MCP tool and serve it"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
basesmcp
Turn any Python function into an auto-registered MCP tool with a single @mcp decorator, then expose them all over a FastMCP server.
Install
pip install basesmcpRelated MCP server: mymcpservercli
Quickstart
from basesmcp import mcp, serve
@mcp
def get_user(user_id: str) -> dict:
"""Fetch a user by id."""
return {"user_id": user_id, "name": "Ada"}
@mcp(name="add_numbers", tags={"math"})
def add(a: float, b: float) -> float:
"""Add two numbers."""
return a + b
if __name__ == "__main__":
serve(name="My Product MCP", host="0.0.0.0", port=8000, path="/mcp")Any function you decorate with @mcp becomes a tool; serve() registers them all and runs the server. The MCP client's model selects the right tool per request from its name, description, and type hints — so write clear docstrings and type hints.
Auto-discovery across modules
Keep tools in a package and let basesmcp import them for you:
from basesmcp import serve
serve(name="My MCP", discover="myproduct.mcp_tools", port=8000)discover accepts a module name, a package name (all submodules are imported), or a list of names.
Auth (optional)
Plug your existing token validation in without basesmcp knowing the details:
from basesmcp import serve, bearer_auth
from fastmcp.server.auth import AccessToken
def verify(token: str):
claims = my_validate(token) # your existing logic
if not claims:
return None
return AccessToken(token=token, client_id=claims["sub"], scopes=claims.get("roles", []))
auth = bearer_auth(
verify=verify,
authorization_servers=["https://auth.example.com"],
base_url="https://mcp.example.com",
)
serve(name="My MCP", auth=auth, host="0.0.0.0", port=8000)Read the caller identity inside a tool:
from basesmcp import mcp, current_token, current_claims
@mcp
def whoami() -> dict:
return {"authenticated": current_token() is not None, "claims": current_claims()}API
Symbol | Purpose |
| Mark a function as a tool (bare or parameterized). |
| Build a FastMCP server with all tools registered. |
| Build and run the server. |
| Optional auth wiring. |
| Current request context. |
| Isolated registry (e.g. for tests). |
Best practice
Decorate framework-agnostic functions (plain functions or your service-layer methods) — not web-framework route handlers that depend on request globals. Give every tool a clear docstring and typed parameters so the client model can route to it accurately.
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Host your MCP tool over streamable HTTP in one command.
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Related MCP Servers
- AlicenseBqualityAmaintenanceA lightweight server implementation that exposes Python functions as discoverable tools via HTTP using the Machine-to-Machine Communication Protocol (MCP). Enables remote execution of Python functions through a JSON-RPC interface with async support and type safety.4MIT
- FlicenseBqualityDmaintenanceA Model Context Protocol server framework featuring dynamic tool loading and automatic tool discovery from a dedicated directory. It leverages FastMCP to provide a robust environment for building, configuring, and testing individual Python-based tools.1-
- FlicenseNot gradedqualityDmaintenanceFramework for building and running MCP servers as HTTP services. Define tools as pure Python functions, wire up with two lines, run with one command.-
- AlicenseNot gradedqualityBmaintenanceConvert plain Python modules into MCP servers without decorators or boilerplate, automatically exposing functions as schematized tools.MIT