Skip to content

Latest commit

 

History

History
242 lines (179 loc) · 5.91 KB

File metadata and controls

242 lines (179 loc) · 5.91 KB
title Arcade MCP (MCP Server SDK) - Python Overview
description Overview of the Arcade MCP (MCP Server SDK) for Python

Arcade MCP (MCP Server SDK) - Python Overview

arcade mcp, the secure framework for building MCP servers, provides a clean, minimal API to build MCP servers programmatically. It handles tool collection, server configuration, and transport setup with a developer-friendly interface.

Basic Usage

from arcade_mcp_server import MCPApp
from typing import Annotated

app = MCPApp(name="my_server", version="1.0.0")

@app.tool
def greet(name: Annotated[str, "The name of the person to greet"]) -> str:
    """Greet a person by name."""
    return f"Hello, {name}!"

app.run(host="127.0.0.1", port=8000)

Class Reference

MCPApp

arcade_mcp_server.mcp_app.MCPApp

A FastAPI-like interface for building MCP servers.

The app collects tools and configuration, then lazily creates the server and transport when run() is called.

Example:

from arcade_mcp_server import MCPApp
from typing import Annotated

app = MCPApp(name="my_server", version="1.0.0")

@app.tool
def greet(name: Annotated[str, "The name of the person to greet"]) -> str:
    """Greet a person by name."""
    return f"Hello, {name}!"

# Runtime CRUD once you have a server bound to the app:
# app.server = mcp_server
# await app.tools.add(materialized_tool)
# await app.prompts.add(prompt, handler)
# await app.resources.add(resource)

app.run(host="127.0.0.1", port=8000)

Properties

prompts

Runtime prompts API: add/remove/list.

resources

Runtime resources API: add/remove/list.

tools

Runtime and build-time tools API: add/update/remove/list.

Methods

__init__
__init__(
    name='ArcadeMCP',
    version='1.0.0dev',
    title=None,
    instructions=None,
    log_level='INFO',
    transport='stdio',
    host='127.0.0.1',
    port=8000,
    reload=False,
    **kwargs
)

Initialize the MCP app.

Parameters:

Name Type Description Default
name str Server name 'ArcadeMCP'
version str Server version '1.0.0dev'
title str | None Server title for display None
instructions str | None Server instructions None
log_level str Logging level (DEBUG, INFO, WARNING, ERROR) 'INFO'
transport TransportType Transport type ("stdio" or "http") 'stdio'
host str Host for transport '127.0.0.1'
port int Port for transport 8000
reload bool Enable auto-reload for development False
**kwargs Any Additional server configuration {}
add_tool
add_tool(
    func,
    desc=None,
    name=None,
    requires_auth=None,
    requires_secrets=None,
    requires_metadata=None,
    adapters=None
)

Add a tool for build-time materialization (pre-server).

tool
tool(
    func=None,
    desc=None,
    name=None,
    requires_auth=None,
    requires_secrets=None,
    requires_metadata=None,
    adapters=None
)

Decorator for adding tools with optional parameters.

Examples

With OAuth Authentication

Use requires_auth when your tool needs to act on behalf of a user. Add a context: Context parameter to access the authorization token.

from arcade_mcp_server import MCPApp, Context
from arcade_mcp_server.auth import Google
from typing import Annotated

app = MCPApp(name="my_server")

@app.tool(requires_auth=Google(scopes=["profile", "email"]))
async def get_profile(
    user_id: Annotated[str, "The user ID to look up"],
    context: Context,
) -> dict:
    """Get user profile from Google."""
    token = context.authorization.token  # OAuth access token
    # Use token to call Google APIs...
    return {"user_id": user_id}

Available auth providers:

from arcade_mcp_server.auth import (
    Google,
    GitHub,
    Slack,
    Microsoft,
    Discord,
    LinkedIn,
    Dropbox,
    # ... and more
)
With Secrets

Use requires_secrets for API keys your server needs. Add a context: Context parameter to access secrets.

from arcade_mcp_server import MCPApp, Context
from typing import Annotated

app = MCPApp(name="my_server")

@app.tool(requires_secrets=["API_KEY"])
async def call_external_api(
    query: Annotated[str, "Search query"],
    context: Context,
) -> str:
    """Call an external API."""
    api_key = context.get_secret("API_KEY")
    # Use api_key to call external service...
    return f"Results for: {query}"
With Lifecycle Hooks

Use @app.on_event for startup/shutdown logic.

from arcade_mcp_server import MCPApp

app = MCPApp(name="my_server")

@app.on_event("startup")
async def on_startup():
    await db.connect()

@app.on_event("shutdown")
async def on_shutdown():
    await db.disconnect()
Full Example
# --- server.py ---
# Programmatic server creation with a simple tool and HTTP transport

from arcade_mcp_server import MCPApp
from typing import Annotated

app = MCPApp(name="example_server", version="1.0.0")

@app.tool
def echo(text: Annotated[str, "The text to echo"]) -> str:
    """Echo the text back."""
    return f"Echo: {text}"

if __name__ == "__main__":
    # Start an HTTP server (good for local development/testing)
    app.run(transport="http", host="0.0.0.0", port=8000, reload=False, debug=True)
# then run the server
python server.py