Skip to content

Commit e7d79e0

Browse files
committed
everything server for REAME snippets
1 parent 7942184 commit e7d79e0

File tree

11 files changed

+598
-245
lines changed

11 files changed

+598
-245
lines changed

.github/workflows/shared.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,19 @@ jobs:
4646
- name: Run pytest
4747
run: uv run --frozen --no-sync pytest
4848
continue-on-error: true
49+
50+
readme-snippets:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- uses: astral-sh/setup-uv@v5
56+
with:
57+
enable-cache: true
58+
version: 0.7.2
59+
60+
- name: Install dependencies
61+
run: uv sync --frozen --all-extras --python 3.10
62+
63+
- name: Check README snippets are up to date
64+
run: uv run --frozen scripts/update_readme_snippets.py --check

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ repos:
3636
language: system
3737
files: ^(pyproject\.toml|uv\.lock)$
3838
pass_filenames: false
39+
- id: readme-snippets
40+
name: Check README snippets are up to date
41+
entry: uv run scripts/update_readme_snippets.py --check
42+
language: system
43+
files: ^(README\.md|examples/.*\.py|scripts/update_readme_snippets\.py)$
44+
pass_filenames: false

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -419,21 +419,27 @@ def create_thumbnail(image_path: str) -> Image:
419419

420420
The Context object gives your tools and resources access to MCP capabilities:
421421

422+
<!-- snippet-source examples/servers/everything/src/everything/server.py#L43-L58 -->
422423
```python
423-
from mcp.server.fastmcp import FastMCP, Context
424-
425-
mcp = FastMCP("My App")
426-
424+
# Tool with context for logging and progress
425+
@mcp.tool(description="A tool that demonstrates logging and progress", title="Progress Tool")
426+
async def tool_with_progress(message: str, ctx: Context, steps: int = 3) -> str:
427+
await ctx.info(f"Starting processing of '{message}' with {steps} steps")
428+
429+
# Send progress notifications
430+
for i in range(steps):
431+
progress_value = (i + 1) / steps
432+
await ctx.report_progress(
433+
progress=progress_value,
434+
total=1.0,
435+
message=f"Processing step {i + 1} of {steps}",
436+
)
437+
await ctx.debug(f"Completed step {i + 1}")
427438

428-
@mcp.tool()
429-
async def long_task(files: list[str], ctx: Context) -> str:
430-
"""Process multiple files with progress tracking"""
431-
for i, file in enumerate(files):
432-
ctx.info(f"Processing {file}")
433-
await ctx.report_progress(i, len(files))
434-
data, mime_type = await ctx.read_resource(f"file://{file}")
435-
return "Processing complete"
439+
return f"Processed '{message}' in {steps} steps"
436440
```
441+
_Full example: [examples/servers/everything/src/everything/server.py](https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/servers/everything/src/everything/server.py#L43-L58)_
442+
<!-- /snippet-source -->
437443

438444
### Completions
439445

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# MCP Everything Server
2+
3+
A comprehensive example MCP server that demonstrates all features of the Model Context Protocol, including:
4+
5+
- Tools with progress reporting, logging, and elicitation
6+
- Resource handling (static, dynamic, and templated)
7+
- Prompts with arguments
8+
- Completion support for resource templates and prompts
9+
- Request context propagation
10+
- Notifications and logging
11+
- Sampling capabilities
12+
- Structured output
13+
14+
## Usage
15+
16+
### Running the server
17+
18+
```bash
19+
uv run mcp-server-everything
20+
```
21+
22+
### Testing with MCP Inspector
23+
24+
```bash
25+
mcp dev "uv run mcp-server-everything"
26+
```
27+
28+
### Installing in Claude Desktop
29+
30+
```bash
31+
mcp install "uv run mcp-server-everything" --name "Everything Server"
32+
```
33+
34+
## Features
35+
36+
This server demonstrates:
37+
38+
- **Tools**: Echo, progress tracking, sampling, notifications, context access, elicitation
39+
- **Resources**: Static resources, dynamic resources with parameters, resource templates
40+
- **Prompts**: Simple and complex prompts with arguments
41+
- **Completions**: Context-aware completion for prompts and resource templates
42+
- **Notifications**: Progress updates, logging at different levels, resource/tool list changes
43+
- **Elicitation**: Interactive user input during tool execution
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[project]
2+
name = "mcp-server-everything"
3+
version = "0.1.0"
4+
description = "Comprehensive MCP server demonstrating all protocol features"
5+
readme = "README.md"
6+
requires-python = ">=3.10"
7+
dependencies = [
8+
"mcp",
9+
"pydantic>=2.0",
10+
"httpx",
11+
]
12+
13+
[project.scripts]
14+
mcp-server-everything = "everything.__main__:main"
15+
16+
[build-system]
17+
requires = ["hatchling"]
18+
build-backend = "hatchling.build"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""MCP Everything Server - Comprehensive example demonstrating all MCP features."""
2+
3+
from .server import create_everything_server
4+
5+
__all__ = ["create_everything_server"]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Main entry point for the Everything Server."""
2+
3+
from .server import create_everything_server
4+
5+
6+
def main():
7+
"""Run the everything server."""
8+
mcp = create_everything_server()
9+
# Use FastMCP's built-in run method for better CLI integration
10+
mcp.run(transport="sse")
11+
12+
13+
if __name__ == "__main__":
14+
main()

0 commit comments

Comments
 (0)