structure saas with tools
This commit is contained in:
@@ -0,0 +1 @@
|
||||
pip
|
||||
687
.venv/lib/python3.10/site-packages/mcp-1.6.0.dist-info/METADATA
Normal file
687
.venv/lib/python3.10/site-packages/mcp-1.6.0.dist-info/METADATA
Normal file
@@ -0,0 +1,687 @@
|
||||
Metadata-Version: 2.4
|
||||
Name: mcp
|
||||
Version: 1.6.0
|
||||
Summary: Model Context Protocol SDK
|
||||
Project-URL: Homepage, https://modelcontextprotocol.io
|
||||
Project-URL: Repository, https://github.com/modelcontextprotocol/python-sdk
|
||||
Project-URL: Issues, https://github.com/modelcontextprotocol/python-sdk/issues
|
||||
Author: Anthropic, PBC.
|
||||
Maintainer-email: David Soria Parra <davidsp@anthropic.com>, Justin Spahr-Summers <justin@anthropic.com>
|
||||
License: MIT
|
||||
License-File: LICENSE
|
||||
Keywords: automation,git,llm,mcp
|
||||
Classifier: Development Status :: 4 - Beta
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.10
|
||||
Classifier: Programming Language :: Python :: 3.11
|
||||
Classifier: Programming Language :: Python :: 3.12
|
||||
Classifier: Programming Language :: Python :: 3.13
|
||||
Requires-Python: >=3.10
|
||||
Requires-Dist: anyio>=4.5
|
||||
Requires-Dist: httpx-sse>=0.4
|
||||
Requires-Dist: httpx>=0.27
|
||||
Requires-Dist: pydantic-settings>=2.5.2
|
||||
Requires-Dist: pydantic<3.0.0,>=2.7.2
|
||||
Requires-Dist: sse-starlette>=1.6.1
|
||||
Requires-Dist: starlette>=0.27
|
||||
Requires-Dist: uvicorn>=0.23.1
|
||||
Provides-Extra: cli
|
||||
Requires-Dist: python-dotenv>=1.0.0; extra == 'cli'
|
||||
Requires-Dist: typer>=0.12.4; extra == 'cli'
|
||||
Provides-Extra: rich
|
||||
Requires-Dist: rich>=13.9.4; extra == 'rich'
|
||||
Provides-Extra: ws
|
||||
Requires-Dist: websockets>=15.0.1; extra == 'ws'
|
||||
Description-Content-Type: text/markdown
|
||||
|
||||
# MCP Python SDK
|
||||
|
||||
<div align="center">
|
||||
|
||||
<strong>Python implementation of the Model Context Protocol (MCP)</strong>
|
||||
|
||||
[![PyPI][pypi-badge]][pypi-url]
|
||||
[![MIT licensed][mit-badge]][mit-url]
|
||||
[![Python Version][python-badge]][python-url]
|
||||
[![Documentation][docs-badge]][docs-url]
|
||||
[![Specification][spec-badge]][spec-url]
|
||||
[![GitHub Discussions][discussions-badge]][discussions-url]
|
||||
|
||||
</div>
|
||||
|
||||
<!-- omit in toc -->
|
||||
## Table of Contents
|
||||
|
||||
- [MCP Python SDK](#mcp-python-sdk)
|
||||
- [Overview](#overview)
|
||||
- [Installation](#installation)
|
||||
- [Adding MCP to your python project](#adding-mcp-to-your-python-project)
|
||||
- [Running the standalone MCP development tools](#running-the-standalone-mcp-development-tools)
|
||||
- [Quickstart](#quickstart)
|
||||
- [What is MCP?](#what-is-mcp)
|
||||
- [Core Concepts](#core-concepts)
|
||||
- [Server](#server)
|
||||
- [Resources](#resources)
|
||||
- [Tools](#tools)
|
||||
- [Prompts](#prompts)
|
||||
- [Images](#images)
|
||||
- [Context](#context)
|
||||
- [Running Your Server](#running-your-server)
|
||||
- [Development Mode](#development-mode)
|
||||
- [Claude Desktop Integration](#claude-desktop-integration)
|
||||
- [Direct Execution](#direct-execution)
|
||||
- [Mounting to an Existing ASGI Server](#mounting-to-an-existing-asgi-server)
|
||||
- [Examples](#examples)
|
||||
- [Echo Server](#echo-server)
|
||||
- [SQLite Explorer](#sqlite-explorer)
|
||||
- [Advanced Usage](#advanced-usage)
|
||||
- [Low-Level Server](#low-level-server)
|
||||
- [Writing MCP Clients](#writing-mcp-clients)
|
||||
- [MCP Primitives](#mcp-primitives)
|
||||
- [Server Capabilities](#server-capabilities)
|
||||
- [Documentation](#documentation)
|
||||
- [Contributing](#contributing)
|
||||
- [License](#license)
|
||||
|
||||
[pypi-badge]: https://img.shields.io/pypi/v/mcp.svg
|
||||
[pypi-url]: https://pypi.org/project/mcp/
|
||||
[mit-badge]: https://img.shields.io/pypi/l/mcp.svg
|
||||
[mit-url]: https://github.com/modelcontextprotocol/python-sdk/blob/main/LICENSE
|
||||
[python-badge]: https://img.shields.io/pypi/pyversions/mcp.svg
|
||||
[python-url]: https://www.python.org/downloads/
|
||||
[docs-badge]: https://img.shields.io/badge/docs-modelcontextprotocol.io-blue.svg
|
||||
[docs-url]: https://modelcontextprotocol.io
|
||||
[spec-badge]: https://img.shields.io/badge/spec-spec.modelcontextprotocol.io-blue.svg
|
||||
[spec-url]: https://spec.modelcontextprotocol.io
|
||||
[discussions-badge]: https://img.shields.io/github/discussions/modelcontextprotocol/python-sdk
|
||||
[discussions-url]: https://github.com/modelcontextprotocol/python-sdk/discussions
|
||||
|
||||
## Overview
|
||||
|
||||
The Model Context Protocol allows applications to provide context for LLMs in a standardized way, separating the concerns of providing context from the actual LLM interaction. This Python SDK implements the full MCP specification, making it easy to:
|
||||
|
||||
- Build MCP clients that can connect to any MCP server
|
||||
- Create MCP servers that expose resources, prompts and tools
|
||||
- Use standard transports like stdio and SSE
|
||||
- Handle all MCP protocol messages and lifecycle events
|
||||
|
||||
## Installation
|
||||
|
||||
### Adding MCP to your python project
|
||||
|
||||
We recommend using [uv](https://docs.astral.sh/uv/) to manage your Python projects. In a uv managed python project, add mcp to dependencies by:
|
||||
|
||||
```bash
|
||||
uv add "mcp[cli]"
|
||||
```
|
||||
|
||||
Alternatively, for projects using pip for dependencies:
|
||||
```bash
|
||||
pip install mcp
|
||||
```
|
||||
|
||||
### Running the standalone MCP development tools
|
||||
|
||||
To run the mcp command with uv:
|
||||
|
||||
```bash
|
||||
uv run mcp
|
||||
```
|
||||
|
||||
## Quickstart
|
||||
|
||||
Let's create a simple MCP server that exposes a calculator tool and some data:
|
||||
|
||||
```python
|
||||
# server.py
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
# Create an MCP server
|
||||
mcp = FastMCP("Demo")
|
||||
|
||||
|
||||
# Add an addition tool
|
||||
@mcp.tool()
|
||||
def add(a: int, b: int) -> int:
|
||||
"""Add two numbers"""
|
||||
return a + b
|
||||
|
||||
|
||||
# Add a dynamic greeting resource
|
||||
@mcp.resource("greeting://{name}")
|
||||
def get_greeting(name: str) -> str:
|
||||
"""Get a personalized greeting"""
|
||||
return f"Hello, {name}!"
|
||||
```
|
||||
|
||||
You can install this server in [Claude Desktop](https://claude.ai/download) and interact with it right away by running:
|
||||
```bash
|
||||
mcp install server.py
|
||||
```
|
||||
|
||||
Alternatively, you can test it with the MCP Inspector:
|
||||
```bash
|
||||
mcp dev server.py
|
||||
```
|
||||
|
||||
## What is MCP?
|
||||
|
||||
The [Model Context Protocol (MCP)](https://modelcontextprotocol.io) lets you build servers that expose data and functionality to LLM applications in a secure, standardized way. Think of it like a web API, but specifically designed for LLM interactions. MCP servers can:
|
||||
|
||||
- Expose data through **Resources** (think of these sort of like GET endpoints; they are used to load information into the LLM's context)
|
||||
- Provide functionality through **Tools** (sort of like POST endpoints; they are used to execute code or otherwise produce a side effect)
|
||||
- Define interaction patterns through **Prompts** (reusable templates for LLM interactions)
|
||||
- And more!
|
||||
|
||||
## Core Concepts
|
||||
|
||||
### Server
|
||||
|
||||
The FastMCP server is your core interface to the MCP protocol. It handles connection management, protocol compliance, and message routing:
|
||||
|
||||
```python
|
||||
# Add lifespan support for startup/shutdown with strong typing
|
||||
from contextlib import asynccontextmanager
|
||||
from collections.abc import AsyncIterator
|
||||
from dataclasses import dataclass
|
||||
|
||||
from fake_database import Database # Replace with your actual DB type
|
||||
|
||||
from mcp.server.fastmcp import Context, FastMCP
|
||||
|
||||
# Create a named server
|
||||
mcp = FastMCP("My App")
|
||||
|
||||
# Specify dependencies for deployment and development
|
||||
mcp = FastMCP("My App", dependencies=["pandas", "numpy"])
|
||||
|
||||
|
||||
@dataclass
|
||||
class AppContext:
|
||||
db: Database
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def app_lifespan(server: FastMCP) -> AsyncIterator[AppContext]:
|
||||
"""Manage application lifecycle with type-safe context"""
|
||||
# Initialize on startup
|
||||
db = await Database.connect()
|
||||
try:
|
||||
yield AppContext(db=db)
|
||||
finally:
|
||||
# Cleanup on shutdown
|
||||
await db.disconnect()
|
||||
|
||||
|
||||
# Pass lifespan to server
|
||||
mcp = FastMCP("My App", lifespan=app_lifespan)
|
||||
|
||||
|
||||
# Access type-safe lifespan context in tools
|
||||
@mcp.tool()
|
||||
def query_db(ctx: Context) -> str:
|
||||
"""Tool that uses initialized resources"""
|
||||
db = ctx.request_context.lifespan_context["db"]
|
||||
return db.query()
|
||||
```
|
||||
|
||||
### Resources
|
||||
|
||||
Resources are how you expose data to LLMs. They're similar to GET endpoints in a REST API - they provide data but shouldn't perform significant computation or have side effects:
|
||||
|
||||
```python
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
mcp = FastMCP("My App")
|
||||
|
||||
|
||||
@mcp.resource("config://app")
|
||||
def get_config() -> str:
|
||||
"""Static configuration data"""
|
||||
return "App configuration here"
|
||||
|
||||
|
||||
@mcp.resource("users://{user_id}/profile")
|
||||
def get_user_profile(user_id: str) -> str:
|
||||
"""Dynamic user data"""
|
||||
return f"Profile data for user {user_id}"
|
||||
```
|
||||
|
||||
### Tools
|
||||
|
||||
Tools let LLMs take actions through your server. Unlike resources, tools are expected to perform computation and have side effects:
|
||||
|
||||
```python
|
||||
import httpx
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
mcp = FastMCP("My App")
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def calculate_bmi(weight_kg: float, height_m: float) -> float:
|
||||
"""Calculate BMI given weight in kg and height in meters"""
|
||||
return weight_kg / (height_m**2)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def fetch_weather(city: str) -> str:
|
||||
"""Fetch current weather for a city"""
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.get(f"https://api.weather.com/{city}")
|
||||
return response.text
|
||||
```
|
||||
|
||||
### Prompts
|
||||
|
||||
Prompts are reusable templates that help LLMs interact with your server effectively:
|
||||
|
||||
```python
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
from mcp.server.fastmcp.prompts import base
|
||||
|
||||
mcp = FastMCP("My App")
|
||||
|
||||
|
||||
@mcp.prompt()
|
||||
def review_code(code: str) -> str:
|
||||
return f"Please review this code:\n\n{code}"
|
||||
|
||||
|
||||
@mcp.prompt()
|
||||
def debug_error(error: str) -> list[base.Message]:
|
||||
return [
|
||||
base.UserMessage("I'm seeing this error:"),
|
||||
base.UserMessage(error),
|
||||
base.AssistantMessage("I'll help debug that. What have you tried so far?"),
|
||||
]
|
||||
```
|
||||
|
||||
### Images
|
||||
|
||||
FastMCP provides an `Image` class that automatically handles image data:
|
||||
|
||||
```python
|
||||
from mcp.server.fastmcp import FastMCP, Image
|
||||
from PIL import Image as PILImage
|
||||
|
||||
mcp = FastMCP("My App")
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def create_thumbnail(image_path: str) -> Image:
|
||||
"""Create a thumbnail from an image"""
|
||||
img = PILImage.open(image_path)
|
||||
img.thumbnail((100, 100))
|
||||
return Image(data=img.tobytes(), format="png")
|
||||
```
|
||||
|
||||
### Context
|
||||
|
||||
The Context object gives your tools and resources access to MCP capabilities:
|
||||
|
||||
```python
|
||||
from mcp.server.fastmcp import FastMCP, Context
|
||||
|
||||
mcp = FastMCP("My App")
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def long_task(files: list[str], ctx: Context) -> str:
|
||||
"""Process multiple files with progress tracking"""
|
||||
for i, file in enumerate(files):
|
||||
ctx.info(f"Processing {file}")
|
||||
await ctx.report_progress(i, len(files))
|
||||
data, mime_type = await ctx.read_resource(f"file://{file}")
|
||||
return "Processing complete"
|
||||
```
|
||||
|
||||
## Running Your Server
|
||||
|
||||
### Development Mode
|
||||
|
||||
The fastest way to test and debug your server is with the MCP Inspector:
|
||||
|
||||
```bash
|
||||
mcp dev server.py
|
||||
|
||||
# Add dependencies
|
||||
mcp dev server.py --with pandas --with numpy
|
||||
|
||||
# Mount local code
|
||||
mcp dev server.py --with-editable .
|
||||
```
|
||||
|
||||
### Claude Desktop Integration
|
||||
|
||||
Once your server is ready, install it in Claude Desktop:
|
||||
|
||||
```bash
|
||||
mcp install server.py
|
||||
|
||||
# Custom name
|
||||
mcp install server.py --name "My Analytics Server"
|
||||
|
||||
# Environment variables
|
||||
mcp install server.py -v API_KEY=abc123 -v DB_URL=postgres://...
|
||||
mcp install server.py -f .env
|
||||
```
|
||||
|
||||
### Direct Execution
|
||||
|
||||
For advanced scenarios like custom deployments:
|
||||
|
||||
```python
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
mcp = FastMCP("My App")
|
||||
|
||||
if __name__ == "__main__":
|
||||
mcp.run()
|
||||
```
|
||||
|
||||
Run it with:
|
||||
```bash
|
||||
python server.py
|
||||
# or
|
||||
mcp run server.py
|
||||
```
|
||||
|
||||
### Mounting to an Existing ASGI Server
|
||||
|
||||
You can mount the SSE server to an existing ASGI server using the `sse_app` method. This allows you to integrate the SSE server with other ASGI applications.
|
||||
|
||||
```python
|
||||
from starlette.applications import Starlette
|
||||
from starlette.routing import Mount, Host
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
|
||||
mcp = FastMCP("My App")
|
||||
|
||||
# Mount the SSE server to the existing ASGI server
|
||||
app = Starlette(
|
||||
routes=[
|
||||
Mount('/', app=mcp.sse_app()),
|
||||
]
|
||||
)
|
||||
|
||||
# or dynamically mount as host
|
||||
app.router.routes.append(Host('mcp.acme.corp', app=mcp.sse_app()))
|
||||
```
|
||||
|
||||
For more information on mounting applications in Starlette, see the [Starlette documentation](https://www.starlette.io/routing/#submounting-routes).
|
||||
|
||||
## Examples
|
||||
|
||||
### Echo Server
|
||||
|
||||
A simple server demonstrating resources, tools, and prompts:
|
||||
|
||||
```python
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
mcp = FastMCP("Echo")
|
||||
|
||||
|
||||
@mcp.resource("echo://{message}")
|
||||
def echo_resource(message: str) -> str:
|
||||
"""Echo a message as a resource"""
|
||||
return f"Resource echo: {message}"
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def echo_tool(message: str) -> str:
|
||||
"""Echo a message as a tool"""
|
||||
return f"Tool echo: {message}"
|
||||
|
||||
|
||||
@mcp.prompt()
|
||||
def echo_prompt(message: str) -> str:
|
||||
"""Create an echo prompt"""
|
||||
return f"Please process this message: {message}"
|
||||
```
|
||||
|
||||
### SQLite Explorer
|
||||
|
||||
A more complex example showing database integration:
|
||||
|
||||
```python
|
||||
import sqlite3
|
||||
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
mcp = FastMCP("SQLite Explorer")
|
||||
|
||||
|
||||
@mcp.resource("schema://main")
|
||||
def get_schema() -> str:
|
||||
"""Provide the database schema as a resource"""
|
||||
conn = sqlite3.connect("database.db")
|
||||
schema = conn.execute("SELECT sql FROM sqlite_master WHERE type='table'").fetchall()
|
||||
return "\n".join(sql[0] for sql in schema if sql[0])
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def query_data(sql: str) -> str:
|
||||
"""Execute SQL queries safely"""
|
||||
conn = sqlite3.connect("database.db")
|
||||
try:
|
||||
result = conn.execute(sql).fetchall()
|
||||
return "\n".join(str(row) for row in result)
|
||||
except Exception as e:
|
||||
return f"Error: {str(e)}"
|
||||
```
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
### Low-Level Server
|
||||
|
||||
For more control, you can use the low-level server implementation directly. This gives you full access to the protocol and allows you to customize every aspect of your server, including lifecycle management through the lifespan API:
|
||||
|
||||
```python
|
||||
from contextlib import asynccontextmanager
|
||||
from collections.abc import AsyncIterator
|
||||
|
||||
from fake_database import Database # Replace with your actual DB type
|
||||
|
||||
from mcp.server import Server
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def server_lifespan(server: Server) -> AsyncIterator[dict]:
|
||||
"""Manage server startup and shutdown lifecycle."""
|
||||
# Initialize resources on startup
|
||||
db = await Database.connect()
|
||||
try:
|
||||
yield {"db": db}
|
||||
finally:
|
||||
# Clean up on shutdown
|
||||
await db.disconnect()
|
||||
|
||||
|
||||
# Pass lifespan to server
|
||||
server = Server("example-server", lifespan=server_lifespan)
|
||||
|
||||
|
||||
# Access lifespan context in handlers
|
||||
@server.call_tool()
|
||||
async def query_db(name: str, arguments: dict) -> list:
|
||||
ctx = server.request_context
|
||||
db = ctx.lifespan_context["db"]
|
||||
return await db.query(arguments["query"])
|
||||
```
|
||||
|
||||
The lifespan API provides:
|
||||
- A way to initialize resources when the server starts and clean them up when it stops
|
||||
- Access to initialized resources through the request context in handlers
|
||||
- Type-safe context passing between lifespan and request handlers
|
||||
|
||||
```python
|
||||
import mcp.server.stdio
|
||||
import mcp.types as types
|
||||
from mcp.server.lowlevel import NotificationOptions, Server
|
||||
from mcp.server.models import InitializationOptions
|
||||
|
||||
# Create a server instance
|
||||
server = Server("example-server")
|
||||
|
||||
|
||||
@server.list_prompts()
|
||||
async def handle_list_prompts() -> list[types.Prompt]:
|
||||
return [
|
||||
types.Prompt(
|
||||
name="example-prompt",
|
||||
description="An example prompt template",
|
||||
arguments=[
|
||||
types.PromptArgument(
|
||||
name="arg1", description="Example argument", required=True
|
||||
)
|
||||
],
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
@server.get_prompt()
|
||||
async def handle_get_prompt(
|
||||
name: str, arguments: dict[str, str] | None
|
||||
) -> types.GetPromptResult:
|
||||
if name != "example-prompt":
|
||||
raise ValueError(f"Unknown prompt: {name}")
|
||||
|
||||
return types.GetPromptResult(
|
||||
description="Example prompt",
|
||||
messages=[
|
||||
types.PromptMessage(
|
||||
role="user",
|
||||
content=types.TextContent(type="text", text="Example prompt text"),
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
async def run():
|
||||
async with mcp.server.stdio.stdio_server() as (read_stream, write_stream):
|
||||
await server.run(
|
||||
read_stream,
|
||||
write_stream,
|
||||
InitializationOptions(
|
||||
server_name="example",
|
||||
server_version="0.1.0",
|
||||
capabilities=server.get_capabilities(
|
||||
notification_options=NotificationOptions(),
|
||||
experimental_capabilities={},
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import asyncio
|
||||
|
||||
asyncio.run(run())
|
||||
```
|
||||
|
||||
### Writing MCP Clients
|
||||
|
||||
The SDK provides a high-level client interface for connecting to MCP servers:
|
||||
|
||||
```python
|
||||
from mcp import ClientSession, StdioServerParameters, types
|
||||
from mcp.client.stdio import stdio_client
|
||||
|
||||
# Create server parameters for stdio connection
|
||||
server_params = StdioServerParameters(
|
||||
command="python", # Executable
|
||||
args=["example_server.py"], # Optional command line arguments
|
||||
env=None, # Optional environment variables
|
||||
)
|
||||
|
||||
|
||||
# Optional: create a sampling callback
|
||||
async def handle_sampling_message(
|
||||
message: types.CreateMessageRequestParams,
|
||||
) -> types.CreateMessageResult:
|
||||
return types.CreateMessageResult(
|
||||
role="assistant",
|
||||
content=types.TextContent(
|
||||
type="text",
|
||||
text="Hello, world! from model",
|
||||
),
|
||||
model="gpt-3.5-turbo",
|
||||
stopReason="endTurn",
|
||||
)
|
||||
|
||||
|
||||
async def run():
|
||||
async with stdio_client(server_params) as (read, write):
|
||||
async with ClientSession(
|
||||
read, write, sampling_callback=handle_sampling_message
|
||||
) as session:
|
||||
# Initialize the connection
|
||||
await session.initialize()
|
||||
|
||||
# List available prompts
|
||||
prompts = await session.list_prompts()
|
||||
|
||||
# Get a prompt
|
||||
prompt = await session.get_prompt(
|
||||
"example-prompt", arguments={"arg1": "value"}
|
||||
)
|
||||
|
||||
# List available resources
|
||||
resources = await session.list_resources()
|
||||
|
||||
# List available tools
|
||||
tools = await session.list_tools()
|
||||
|
||||
# Read a resource
|
||||
content, mime_type = await session.read_resource("file://some/path")
|
||||
|
||||
# Call a tool
|
||||
result = await session.call_tool("tool-name", arguments={"arg1": "value"})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import asyncio
|
||||
|
||||
asyncio.run(run())
|
||||
```
|
||||
|
||||
### MCP Primitives
|
||||
|
||||
The MCP protocol defines three core primitives that servers can implement:
|
||||
|
||||
| Primitive | Control | Description | Example Use |
|
||||
|-----------|-----------------------|-----------------------------------------------------|------------------------------|
|
||||
| Prompts | User-controlled | Interactive templates invoked by user choice | Slash commands, menu options |
|
||||
| Resources | Application-controlled| Contextual data managed by the client application | File contents, API responses |
|
||||
| Tools | Model-controlled | Functions exposed to the LLM to take actions | API calls, data updates |
|
||||
|
||||
### Server Capabilities
|
||||
|
||||
MCP servers declare capabilities during initialization:
|
||||
|
||||
| Capability | Feature Flag | Description |
|
||||
|-------------|------------------------------|------------------------------------|
|
||||
| `prompts` | `listChanged` | Prompt template management |
|
||||
| `resources` | `subscribe`<br/>`listChanged`| Resource exposure and updates |
|
||||
| `tools` | `listChanged` | Tool discovery and execution |
|
||||
| `logging` | - | Server logging configuration |
|
||||
| `completion`| - | Argument completion suggestions |
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Model Context Protocol documentation](https://modelcontextprotocol.io)
|
||||
- [Model Context Protocol specification](https://spec.modelcontextprotocol.io)
|
||||
- [Officially supported servers](https://github.com/modelcontextprotocol/servers)
|
||||
|
||||
## Contributing
|
||||
|
||||
We are passionate about supporting contributors of all levels of experience and would love to see you get involved in the project. See the [contributing guide](CONTRIBUTING.md) to get started.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the LICENSE file for details.
|
||||
104
.venv/lib/python3.10/site-packages/mcp-1.6.0.dist-info/RECORD
Normal file
104
.venv/lib/python3.10/site-packages/mcp-1.6.0.dist-info/RECORD
Normal file
@@ -0,0 +1,104 @@
|
||||
../../../bin/mcp,sha256=3-vvOiRtXvyKbG-H1aZGA_boCHkOhUBew1pnrMUTgGY,246
|
||||
mcp-1.6.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
mcp-1.6.0.dist-info/METADATA,sha256=Q27I0e3srBfOfvzdXPi7WI2fh3ADhiaiaCnHQOEMjx8,20085
|
||||
mcp-1.6.0.dist-info/RECORD,,
|
||||
mcp-1.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
||||
mcp-1.6.0.dist-info/entry_points.txt,sha256=gnGBbo3yGF0YJNXfZpgkAg1-CQtKxnzxrlA53c8viYA,42
|
||||
mcp-1.6.0.dist-info/licenses/LICENSE,sha256=XhPbvB0SD8KgPOzefJFCSuLX3hG2PVje0vRDHiYe5Q0,1071
|
||||
mcp/__init__.py,sha256=fKCgOdN7cn7gR3YGFaGyV5Goe8A2sEyllLcsRkN0i-g,2601
|
||||
mcp/__pycache__/__init__.cpython-310.pyc,,
|
||||
mcp/__pycache__/types.cpython-310.pyc,,
|
||||
mcp/cli/__init__.py,sha256=Ii284TNoG5lxTP40ETMGhHEq3lQZWxu9m9JuU57kUpQ,87
|
||||
mcp/cli/__pycache__/__init__.cpython-310.pyc,,
|
||||
mcp/cli/__pycache__/claude.cpython-310.pyc,,
|
||||
mcp/cli/__pycache__/cli.cpython-310.pyc,,
|
||||
mcp/cli/claude.py,sha256=vMDSuu9FbdxwPkGw1AqIIKuf2MKD8Oz-mUEjRbby2OI,4602
|
||||
mcp/cli/cli.py,sha256=Zk6GJCnFKVc_IQC9JSMp0S6W0pwEg-SPK_h3GimeqBw,13919
|
||||
mcp/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
mcp/client/__main__.py,sha256=caPrguG-counsZcDDDVvQrvCNUyannquX37bBe5zXmY,2506
|
||||
mcp/client/__pycache__/__init__.cpython-310.pyc,,
|
||||
mcp/client/__pycache__/__main__.cpython-310.pyc,,
|
||||
mcp/client/__pycache__/session.cpython-310.pyc,,
|
||||
mcp/client/__pycache__/sse.cpython-310.pyc,,
|
||||
mcp/client/__pycache__/websocket.cpython-310.pyc,,
|
||||
mcp/client/session.py,sha256=VjHWuXF2YhgyoC8Y8cuaWhSrDXQhV92kFZ4d-uXzI5I,12778
|
||||
mcp/client/sse.py,sha256=DKkyIIwrQQ9xERUnkGKc82irPAunHSGZrPlmWoToqhk,6755
|
||||
mcp/client/stdio/__init__.py,sha256=BaTuFuvctTi_LI7KRqZBarAa3LZ8EAbjgjgMHTRL-Vs,6399
|
||||
mcp/client/stdio/__pycache__/__init__.cpython-310.pyc,,
|
||||
mcp/client/stdio/__pycache__/win32.cpython-310.pyc,,
|
||||
mcp/client/stdio/win32.py,sha256=1AHfXYEx8u0JsCQTZV03ARdgfTdPVLrRj3-I5lEE6D8,3118
|
||||
mcp/client/websocket.py,sha256=dGcDwVts9RZmMTaLIUYz1W2nIjDnaoIBiwS4Nqnxc2E,3427
|
||||
mcp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
mcp/server/__init__.py,sha256=jeMjAkvChhKLEy1fpeKJ4d_bT1vnnmuGm11otQ7ncBg,202
|
||||
mcp/server/__main__.py,sha256=KakUSquF7R44Ugwg3N5VQCJsPnsEVrbwk-UnRHerVww,1328
|
||||
mcp/server/__pycache__/__init__.cpython-310.pyc,,
|
||||
mcp/server/__pycache__/__main__.cpython-310.pyc,,
|
||||
mcp/server/__pycache__/models.cpython-310.pyc,,
|
||||
mcp/server/__pycache__/session.cpython-310.pyc,,
|
||||
mcp/server/__pycache__/sse.cpython-310.pyc,,
|
||||
mcp/server/__pycache__/stdio.cpython-310.pyc,,
|
||||
mcp/server/__pycache__/websocket.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/__init__.py,sha256=eKX65QpJ_Y4Pzne6El54KNyOittXQsPkK387nO2PH7k,245
|
||||
mcp/server/fastmcp/__pycache__/__init__.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/__pycache__/exceptions.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/__pycache__/server.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/exceptions.py,sha256=q9djUDmpwmGEWcHI8q4UzJBtf7s7UtgL--OB7OaGzyQ,435
|
||||
mcp/server/fastmcp/prompts/__init__.py,sha256=4BsMxoYolpoxg74xkkkzCFL8vvdkLVJ5cIPNs1ND1Jo,99
|
||||
mcp/server/fastmcp/prompts/__pycache__/__init__.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/prompts/__pycache__/base.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/prompts/__pycache__/manager.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/prompts/__pycache__/prompt_manager.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/prompts/base.py,sha256=SW0mxjKncoXwS0jCnoaeXP8ATvRXC8bLsJtdZe0qMKI,5719
|
||||
mcp/server/fastmcp/prompts/manager.py,sha256=kEGiKfIxM9X3XIBxog9ZVn9NgUXpBFEDLY7FOOI-Z0A,1485
|
||||
mcp/server/fastmcp/prompts/prompt_manager.py,sha256=8GG1mtrgWfeBnFh8CFAb8V5JF18mToQyJPcHyKOYQAo,1112
|
||||
mcp/server/fastmcp/resources/__init__.py,sha256=e4S369jBoJt07ez9_ZaJefzGfz4kr9nGwG4KPMzMHc8,464
|
||||
mcp/server/fastmcp/resources/__pycache__/__init__.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/resources/__pycache__/base.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/resources/__pycache__/resource_manager.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/resources/__pycache__/templates.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/resources/__pycache__/types.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/resources/base.py,sha256=UFl1SalsiRsicCUw_ItTUl4BnSW4WeV-aMIr0BI7spY,1355
|
||||
mcp/server/fastmcp/resources/resource_manager.py,sha256=wJB9pLI7TgQmfaNJaOphgbrAHH7vcP5S8xMYp559QE4,3314
|
||||
mcp/server/fastmcp/resources/templates.py,sha256=gPFokE-0I0QpM3MXDIbJksh5kOMgTPqZyJ8hEfeiCkI,2972
|
||||
mcp/server/fastmcp/resources/types.py,sha256=BqtqMo3tEdyXg61GnrR032ctuBZ0ai9RnIHXNWDGYKQ,6197
|
||||
mcp/server/fastmcp/server.py,sha256=nuRMr7he1B6IYaFsPy8yMgGFzaN-RZG693u5HSSqnCA,24591
|
||||
mcp/server/fastmcp/tools/__init__.py,sha256=ZboxhyMJDl87Svjov8YwNYwNZi55P9VhmpTjBZLesnk,96
|
||||
mcp/server/fastmcp/tools/__pycache__/__init__.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/tools/__pycache__/base.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/tools/__pycache__/tool_manager.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/tools/base.py,sha256=vlEnvtU5mO6c3MHDN_tv1eI9Fkvl5zkEgH0m-aS2kD0,3076
|
||||
mcp/server/fastmcp/tools/tool_manager.py,sha256=rkplKS4OHUHQvutmlb1DV5WDIJRiDXugwrKwgTiEh50,1884
|
||||
mcp/server/fastmcp/utilities/__init__.py,sha256=-imJ8S-rXmbXMWeDamldP-dHDqAPg_wwmPVz-LNX14E,31
|
||||
mcp/server/fastmcp/utilities/__pycache__/__init__.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/utilities/__pycache__/func_metadata.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/utilities/__pycache__/logging.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/utilities/__pycache__/types.cpython-310.pyc,,
|
||||
mcp/server/fastmcp/utilities/func_metadata.py,sha256=5rC56YHW92Fu6Vza7zNOdkuzQ2YZlG68jhXAriKxlSs,7751
|
||||
mcp/server/fastmcp/utilities/logging.py,sha256=l5ZuuVDK9VZIApTUBqFRkEneCx9y-18HcvME2o1t90k,1003
|
||||
mcp/server/fastmcp/utilities/types.py,sha256=rsNHw-O0IfZrCPkSQbmM-hJ2We8lnqra834HbtD2Clo,1760
|
||||
mcp/server/lowlevel/__init__.py,sha256=mS7slrVoWzHMYqDHDIJ7oRZxwPZG_I63UVQiJN311YY,93
|
||||
mcp/server/lowlevel/__pycache__/__init__.cpython-310.pyc,,
|
||||
mcp/server/lowlevel/__pycache__/helper_types.cpython-310.pyc,,
|
||||
mcp/server/lowlevel/__pycache__/server.cpython-310.pyc,,
|
||||
mcp/server/lowlevel/helper_types.py,sha256=LmzGNx9FU258TKDyKjwfzH_KOnH4Mkk_k8i9EIFmN7Y,189
|
||||
mcp/server/lowlevel/server.py,sha256=Q4CiSvXYHxZ41poawut0wmSOoLIQo7sR34BrvhL6hnU,21248
|
||||
mcp/server/models.py,sha256=CorDHOKBymdOW42pHTE7jclSPXRSOpWQeR8meqbYtsc,341
|
||||
mcp/server/session.py,sha256=433gRLefagSPVYDkJcKmlij2vUHclAzn27sOPU4yOfI,11464
|
||||
mcp/server/sse.py,sha256=8aPnjn5aH72PtdBqcjiR3Jpm4oF4wLWh2npxDV9ZdyA,6721
|
||||
mcp/server/stdio.py,sha256=a95ZjG3miuha1GBdj4Ln5Cz7DMhfpqLlsF8xzd6mGrE,3182
|
||||
mcp/server/websocket.py,sha256=k0MS97RLjAPUeESE7ztL4lPoQYOh57BqWReamcanAJo,2216
|
||||
mcp/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
mcp/shared/__pycache__/__init__.cpython-310.pyc,,
|
||||
mcp/shared/__pycache__/context.cpython-310.pyc,,
|
||||
mcp/shared/__pycache__/exceptions.cpython-310.pyc,,
|
||||
mcp/shared/__pycache__/memory.cpython-310.pyc,,
|
||||
mcp/shared/__pycache__/progress.cpython-310.pyc,,
|
||||
mcp/shared/__pycache__/session.cpython-310.pyc,,
|
||||
mcp/shared/__pycache__/version.cpython-310.pyc,,
|
||||
mcp/shared/context.py,sha256=m9JPs_37Jo4PjlR_ao7mDESpLA6M7M7j-E5VUt9Vlc4,514
|
||||
mcp/shared/exceptions.py,sha256=nmIg0QU_QZk2-mZ2YiJr5Ll9kkVmp_6pQtLGUCp8cDs,316
|
||||
mcp/shared/memory.py,sha256=rC5GEohzYg0mOZpw-tT1wIXZf_kFKjobupLU95zJecI,3355
|
||||
mcp/shared/progress.py,sha256=xitY8-y5C7coZ0zzzT2ynNNNkmFqDTiwXyJZO3BQcnc,1909
|
||||
mcp/shared/session.py,sha256=mYHv6x2eIflZ7xzcBNSkTpaTb4w0lz8zufnCsXPdz0g,14576
|
||||
mcp/shared/version.py,sha256=3OEOejU7T6mc2aZE8NTQUxzknYiyyqqrh6BZG_wXR_U,123
|
||||
mcp/types.py,sha256=-7P4SSy_qvlbOcX4uGl40ebIJL6z7TNHzeFw2PuiH6U,33758
|
||||
@@ -0,0 +1,4 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: hatchling 1.27.0
|
||||
Root-Is-Purelib: true
|
||||
Tag: py3-none-any
|
||||
@@ -0,0 +1,2 @@
|
||||
[console_scripts]
|
||||
mcp = mcp.cli:app [cli]
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Anthropic, PBC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
Reference in New Issue
Block a user