Skip to content

Commit f46dcb1

Browse files
committed
Merge remote-tracking branch 'origin/main' into praboud/auth
# Conflicts: # src/mcp/server/fastmcp/server.py # uv.lock
2 parents 8c251c9 + babb477 commit f46dcb1

File tree

22 files changed

+282
-76
lines changed

22 files changed

+282
-76
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish Docs manually
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
docs-publish:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Configure Git Credentials
14+
run: |
15+
git config user.name github-actions[bot]
16+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
17+
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v3
20+
with:
21+
enable-cache: true
22+
23+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
24+
- uses: actions/cache@v4
25+
with:
26+
key: mkdocs-material-${{ env.cache_id }}
27+
path: .cache
28+
restore-keys: |
29+
mkdocs-material-
30+
31+
- run: uv sync --frozen --group docs
32+
- run: uv run --no-sync mkdocs gh-deploy --force

.github/workflows/publish-pypi.yml

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ jobs:
1010
runs-on: ubuntu-latest
1111
needs: [checks]
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v4
1414

15-
- name: Install uv
16-
uses: astral-sh/setup-uv@v3
17-
with:
18-
enable-cache: true
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v3
17+
with:
18+
enable-cache: true
1919

20-
- name: Set up Python 3.12
21-
run: uv python install 3.12
20+
- name: Set up Python 3.12
21+
run: uv python install 3.12
2222

23-
- name: Build
24-
run: uv build
23+
- name: Build
24+
run: uv build
2525

26-
- name: Upload artifacts
27-
uses: actions/upload-artifact@v4
28-
with:
29-
name: release-dists
30-
path: dist/
26+
- name: Upload artifacts
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: release-dists
30+
path: dist/
3131

3232
checks:
3333
uses: ./.github/workflows/shared.yml
@@ -39,17 +39,17 @@ jobs:
3939
needs:
4040
- release-build
4141
permissions:
42-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
42+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
4343

4444
steps:
45-
- name: Retrieve release distributions
46-
uses: actions/download-artifact@v4
47-
with:
48-
name: release-dists
49-
path: dist/
45+
- name: Retrieve release distributions
46+
uses: actions/download-artifact@v4
47+
with:
48+
name: release-dists
49+
path: dist/
5050

51-
- name: Publish package distributions to PyPI
52-
uses: pypa/gh-action-pypi-publish@release/v1
51+
- name: Publish package distributions to PyPI
52+
uses: pypa/gh-action-pypi-publish@release/v1
5353

5454
docs-publish:
5555
runs-on: ubuntu-latest
@@ -62,16 +62,19 @@ jobs:
6262
run: |
6363
git config user.name github-actions[bot]
6464
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
65-
- name: "Set up Python"
66-
uses: actions/setup-python@v5
65+
66+
- name: Install uv
67+
uses: astral-sh/setup-uv@v3
6768
with:
68-
python-version-file: ".python-version"
69+
enable-cache: true
70+
6971
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
7072
- uses: actions/cache@v4
7173
with:
7274
key: mkdocs-material-${{ env.cache_id }}
7375
path: .cache
7476
restore-keys: |
7577
mkdocs-material-
78+
7679
- run: uv sync --frozen --group docs
7780
- run: uv run --no-sync mkdocs gh-deploy --force

.pre-commit-config.yaml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,29 @@ repos:
77
- id: prettier
88
types_or: [yaml, json5]
99

10-
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.8.1
10+
- repo: local
1211
hooks:
1312
- id: ruff-format
13+
name: Ruff Format
14+
entry: uv run ruff
15+
args: [format]
16+
language: system
17+
types: [python]
18+
pass_filenames: false
1419
- id: ruff
15-
args: [--fix, --exit-non-zero-on-fix]
16-
17-
- repo: local
18-
hooks:
20+
name: Ruff
21+
entry: uv run ruff
22+
args: ["check", "--fix", "--exit-non-zero-on-fix"]
23+
types: [python]
24+
language: system
25+
pass_filenames: false
26+
- id: pyright
27+
name: pyright
28+
entry: uv run pyright
29+
args: [src]
30+
language: system
31+
types: [python]
32+
pass_filenames: false
1933
- id: uv-lock-check
2034
name: Check uv.lock is up to date
2135
entry: uv lock --check

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,24 @@ The Model Context Protocol allows applications to provide context for LLMs in a
7373

7474
### Adding MCP to your python project
7575

76-
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:
76+
We recommend using [uv](https://docs.astral.sh/uv/) to manage your Python projects.
7777

78-
```bash
79-
uv add "mcp[cli]"
80-
```
78+
If you haven't created a uv-managed project yet, create one:
79+
80+
```bash
81+
uv init mcp-server-demo
82+
cd mcp-server-demo
83+
```
84+
85+
Then add MCP to your project dependencies:
86+
87+
```bash
88+
uv add "mcp[cli]"
89+
```
8190

8291
Alternatively, for projects using pip for dependencies:
8392
```bash
84-
pip install mcp
93+
pip install "mcp[cli]"
8594
```
8695

8796
### Running the standalone MCP development tools
@@ -185,7 +194,7 @@ mcp = FastMCP("My App", lifespan=app_lifespan)
185194
@mcp.tool()
186195
def query_db(ctx: Context) -> str:
187196
"""Tool that uses initialized resources"""
188-
db = ctx.request_context.lifespan_context["db"]
197+
db = ctx.request_context.lifespan_context.db
189198
return db.query()
190199
```
191200

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
GROQ_API_KEY=gsk_1234567890
1+
LLM_API_KEY=gsk_1234567890

examples/clients/simple-chatbot/mcp_simple_chatbot/main.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@ async def list_tools(self) -> list[Any]:
122122

123123
for item in tools_response:
124124
if isinstance(item, tuple) and item[0] == "tools":
125-
for tool in item[1]:
126-
tools.append(Tool(tool.name, tool.description, tool.inputSchema))
125+
tools.extend(
126+
Tool(tool.name, tool.description, tool.inputSchema)
127+
for tool in item[1]
128+
)
127129

128130
return tools
129131

@@ -282,10 +284,9 @@ def __init__(self, servers: list[Server], llm_client: LLMClient) -> None:
282284

283285
async def cleanup_servers(self) -> None:
284286
"""Clean up all servers properly."""
285-
cleanup_tasks = []
286-
for server in self.servers:
287-
cleanup_tasks.append(asyncio.create_task(server.cleanup()))
288-
287+
cleanup_tasks = [
288+
asyncio.create_task(server.cleanup()) for server in self.servers
289+
]
289290
if cleanup_tasks:
290291
try:
291292
await asyncio.gather(*cleanup_tasks, return_exceptions=True)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
22

3-
from server import main
3+
from .server import main
44

55
sys.exit(main())
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
22

3-
from server import main
3+
from .server import main
44

55
sys.exit(main())

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ strict: true
55
repo_name: modelcontextprotocol/python-sdk
66
repo_url: https://github.com/modelcontextprotocol/python-sdk
77
edit_uri: edit/main/docs/
8+
site_url: https://modelcontextprotocol.github.io/python-sdk
89

910
# TODO(Marcelo): Add Anthropic copyright?
1011
# copyright: © Model Context Protocol 2025 to present

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies = [
2929
"starlette>=0.27",
3030
"sse-starlette>=1.6.1",
3131
"pydantic-settings>=2.5.2",
32-
"uvicorn>=0.23.1",
32+
"uvicorn>=0.23.1; sys_platform != 'emscripten'",
3333
]
3434

3535
[project.optional-dependencies]
@@ -89,8 +89,8 @@ venv = ".venv"
8989
strict = ["src/mcp/**/*.py"]
9090

9191
[tool.ruff.lint]
92-
select = ["E", "F", "I", "UP"]
93-
ignore = []
92+
select = ["C4", "E", "F", "I", "PERF", "UP"]
93+
ignore = ["PERF203"]
9494

9595
[tool.ruff]
9696
line-length = 88

0 commit comments

Comments
 (0)