swadhinbiswas docs: add 5 more undocumented feature pages (155 total pages) · 7/25/2026
9a3684a
75 lines · 1.8 KB
Raw Download

title: MCP Server
description: Built-in MCP (Model Context Protocol) server for AI agent integration in JustAPI.
keywords: [JustAPI, MCP, agent, AI, tools, Model Context Protocol]

Register Tools

Expose your routes as MCP tools:

from justapi import JustAPIApp

app = JustAPIApp()

@app.tool
def get_weather(city: str) -> dict:
    """Get current weather for a city."""
    return {"city": city, "temp": 72, "condition": "sunny"}

@app.tool(name="search_db", description="Search the database")
def search(query: str) -> list:
    return db.search(query)

List Tools

tools = app.list_tools()
# Returns list of MCP tool descriptors

Call Tools

result = app.call_tool("get_weather", {"city": "London"})
# Returns: {"city": "London", "temp": 72, "condition": "sunny"}

Built-in MCP Tools

JustAPI registers these introspection tools automatically:

Tool Description
list_routes List all registered API routes
get_signature Full signature for one route
explain_endpoint Natural-language explanation of an endpoint
generate_snippet Client code snippet for an endpoint

MCP Server CLI

Run the MCP stdio server for agent integration:

python -m justapi.mcp_server --base-url http://localhost:8000

System Routes

With app.enable_system_routes(), these routes expose tool data:

Route Description
/_system/tools List registered tools
/_system/tools/call Invoke a tool by name
/_system/help Rich route descriptors
/_system/help/{name} Detailed help for one route

See Also