Skip to content

Commit 2709b97

Browse files
authored
Merge branch 'main' into RFC9728_www-authentication
2 parents 2bc58db + 7bc190b commit 2709b97

File tree

22 files changed

+69
-70
lines changed

22 files changed

+69
-70
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ def get_greeting(name: str) -> str:
133133

134134
You can install this server in [Claude Desktop](https://claude.ai/download) and interact with it right away by running:
135135
```bash
136-
mcp install server.py
136+
uv run mcp install server.py
137137
```
138138

139139
Alternatively, you can test it with the MCP Inspector:
140140
```bash
141-
mcp dev server.py
141+
uv run mcp dev server.py
142142
```
143143

144144
## What is MCP?
@@ -589,28 +589,28 @@ See [TokenVerifier](src/mcp/server/auth/provider.py) for more details on impleme
589589
The fastest way to test and debug your server is with the MCP Inspector:
590590

591591
```bash
592-
mcp dev server.py
592+
uv run mcp dev server.py
593593

594594
# Add dependencies
595-
mcp dev server.py --with pandas --with numpy
595+
uv run mcp dev server.py --with pandas --with numpy
596596

597597
# Mount local code
598-
mcp dev server.py --with-editable .
598+
uv run mcp dev server.py --with-editable .
599599
```
600600

601601
### Claude Desktop Integration
602602

603603
Once your server is ready, install it in Claude Desktop:
604604

605605
```bash
606-
mcp install server.py
606+
uv run mcp install server.py
607607

608608
# Custom name
609-
mcp install server.py --name "My Analytics Server"
609+
uv run mcp install server.py --name "My Analytics Server"
610610

611611
# Environment variables
612-
mcp install server.py -v API_KEY=abc123 -v DB_URL=postgres://...
613-
mcp install server.py -f .env
612+
uv run mcp install server.py -v API_KEY=abc123 -v DB_URL=postgres://...
613+
uv run mcp install server.py -f .env
614614
```
615615

616616
### Direct Execution
@@ -630,10 +630,10 @@ Run it with:
630630
```bash
631631
python server.py
632632
# or
633-
mcp run server.py
633+
uv run mcp run server.py
634634
```
635635

636-
Note that `mcp run` or `mcp dev` only supports server using FastMCP and not the low-level server variant.
636+
Note that `uv run mcp run` or `uv run mcp dev` only supports server using FastMCP and not the low-level server variant.
637637

638638
### Streamable HTTP Transport
639639

@@ -949,7 +949,7 @@ if __name__ == "__main__":
949949
asyncio.run(run())
950950
```
951951

952-
Caution: The `mcp run` and `mcp dev` tool doesn't support low-level server.
952+
Caution: The `uv run mcp run` and `uv run mcp dev` tool doesn't support low-level server.
953953

954954
#### Structured Output Support
955955

examples/clients/simple-auth-client/mcp_simple_auth_client/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def do_GET(self):
8181
<html>
8282
<body>
8383
<h1>Authorization Failed</h1>
84-
<p>Error: {query_params['error'][0]}</p>
84+
<p>Error: {query_params["error"][0]}</p>
8585
<p>You can close this window and return to the terminal.</p>
8686
</body>
8787
</html>

examples/fastmcp/memory.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from dataclasses import dataclass
1717
from datetime import datetime, timezone
1818
from pathlib import Path
19-
from typing import Annotated, Self
19+
from typing import Annotated, Self, TypeVar
2020

2121
import asyncpg
2222
import numpy as np
@@ -35,6 +35,8 @@
3535
DEFAULT_LLM_MODEL = "openai:gpt-4o"
3636
DEFAULT_EMBEDDING_MODEL = "text-embedding-3-small"
3737

38+
T = TypeVar("T")
39+
3840
mcp = FastMCP(
3941
"memory",
4042
dependencies=[
@@ -57,7 +59,7 @@ def cosine_similarity(a: list[float], b: list[float]) -> float:
5759
return np.dot(a_array, b_array) / (np.linalg.norm(a_array) * np.linalg.norm(b_array))
5860

5961

60-
async def do_ai[T](
62+
async def do_ai(
6163
user_prompt: str,
6264
system_prompt: str,
6365
result_type: type[T] | Annotated,

examples/fastmcp/unicode_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
mcp = FastMCP()
99

1010

11-
@mcp.tool(description="🌟 A tool that uses various Unicode characters in its description: " "á é í ó ú ñ 漢字 🎉")
11+
@mcp.tool(description="🌟 A tool that uses various Unicode characters in its description: á é í ó ú ñ 漢字 🎉")
1212
def hello_unicode(name: str = "世界", greeting: str = "¡Hola") -> str:
1313
"""
1414
A simple tool that demonstrates Unicode handling in:

examples/servers/simple-auth/mcp_simple_auth/simple_auth_provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async def authorize(self, client: OAuthClientInformationFull, params: Authorizat
8989
}
9090

9191
# Build simple login URL that points to login page
92-
auth_url = f"{self.auth_callback_url}" f"?state={state}" f"&client_id={client.client_id}"
92+
auth_url = f"{self.auth_callback_url}?state={state}&client_id={client.client_id}"
9393

9494
return auth_url
9595

@@ -117,7 +117,7 @@ async def get_login_page(self, state: str) -> HTMLResponse:
117117
<p><strong>Username:</strong> demo_user<br>
118118
<strong>Password:</strong> demo_password</p>
119119
120-
<form action="{self.server_url.rstrip('/')}/login/callback" method="post">
120+
<form action="{self.server_url.rstrip("/")}/login/callback" method="post">
121121
<input type="hidden" name="state" value="{state}">
122122
<div class="form-group">
123123
<label>Username:</label>

examples/servers/simple-streamablehttp-stateless/mcp_simple_streamablehttp_stateless/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async def call_tool(name: str, arguments: dict) -> list[types.ContentBlock]:
5151
for i in range(count):
5252
await ctx.session.send_log_message(
5353
level="info",
54-
data=f"Notification {i+1}/{count} from caller: {caller}",
54+
data=f"Notification {i + 1}/{count} from caller: {caller}",
5555
logger="notification_stream",
5656
related_request_id=ctx.request_id,
5757
)

examples/servers/simple-streamablehttp/mcp_simple_streamablehttp/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async def call_tool(name: str, arguments: dict) -> list[types.ContentBlock]:
5555
for i in range(count):
5656
# Include more detailed message for resumability demonstration
5757
notification_msg = (
58-
f"[{i+1}/{count}] Event from '{caller}' - "
58+
f"[{i + 1}/{count}] Event from '{caller}' - "
5959
f"Use Last-Event-ID to resume if disconnected"
6060
)
6161
await ctx.session.send_log_message(
@@ -69,7 +69,7 @@ async def call_tool(name: str, arguments: dict) -> list[types.ContentBlock]:
6969
# - nowhere (if GET request isn't supported)
7070
related_request_id=ctx.request_id,
7171
)
72-
logger.debug(f"Sent notification {i+1}/{count} for caller: {caller}")
72+
logger.debug(f"Sent notification {i + 1}/{count} for caller: {caller}")
7373
if i < count - 1: # Don't wait after the last notification
7474
await anyio.sleep(interval)
7575

src/mcp/cli/claude.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_uv_path() -> str:
3535
uv_path = shutil.which("uv")
3636
if not uv_path:
3737
logger.error(
38-
"uv executable not found in PATH, falling back to 'uv'. " "Please ensure uv is installed and in your PATH"
38+
"uv executable not found in PATH, falling back to 'uv'. Please ensure uv is installed and in your PATH"
3939
)
4040
return "uv" # Fall back to just "uv" if not found
4141
return uv_path

src/mcp/cli/cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ def _check_server_object(server_object: Any, object_name: str):
150150
True if it's supported.
151151
"""
152152
if not isinstance(server_object, FastMCP):
153-
logger.error(f"The server object {object_name} is of type " f"{type(server_object)} (expecting {FastMCP}).")
153+
logger.error(f"The server object {object_name} is of type {type(server_object)} (expecting {FastMCP}).")
154154
if isinstance(server_object, LowLevelServer):
155155
logger.warning(
156-
"Note that only FastMCP server is supported. Low level " "Server class is not yet supported."
156+
"Note that only FastMCP server is supported. Low level Server class is not yet supported."
157157
)
158158
return False
159159
return True
@@ -164,7 +164,7 @@ def _check_server_object(server_object: Any, object_name: str):
164164
for name in ["mcp", "server", "app"]:
165165
if hasattr(module, name):
166166
if not _check_server_object(getattr(module, name), f"{file}:{name}"):
167-
logger.error(f"Ignoring object '{file}:{name}' as it's not a valid " "server object")
167+
logger.error(f"Ignoring object '{file}:{name}' as it's not a valid server object")
168168
continue
169169
return getattr(module, name)
170170

@@ -269,7 +269,7 @@ def dev(
269269
npx_cmd = _get_npx_command()
270270
if not npx_cmd:
271271
logger.error(
272-
"npx not found. Please ensure Node.js and npm are properly installed " "and added to your system PATH."
272+
"npx not found. Please ensure Node.js and npm are properly installed and added to your system PATH."
273273
)
274274
sys.exit(1)
275275

@@ -371,7 +371,7 @@ def install(
371371
typer.Option(
372372
"--name",
373373
"-n",
374-
help="Custom name for the server (defaults to server's name attribute or" " file name)",
374+
help="Custom name for the server (defaults to server's name attribute or file name)",
375375
),
376376
] = None,
377377
with_editable: Annotated[
@@ -445,7 +445,7 @@ def install(
445445
name = server.name
446446
except (ImportError, ModuleNotFoundError) as e:
447447
logger.debug(
448-
"Could not import server (likely missing dependencies), using file" " name",
448+
"Could not import server (likely missing dependencies), using file name",
449449
extra={"error": str(e)},
450450
)
451451
name = file.stem

src/mcp/client/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ async def initialize(self) -> types.InitializeResult:
168168
)
169169

170170
if result.protocolVersion not in SUPPORTED_PROTOCOL_VERSIONS:
171-
raise RuntimeError("Unsupported protocol version from the server: " f"{result.protocolVersion}")
171+
raise RuntimeError(f"Unsupported protocol version from the server: {result.protocolVersion}")
172172

173173
await self.send_notification(
174174
types.ClientNotification(types.InitializedNotification(method="notifications/initialized"))

0 commit comments

Comments
 (0)