Skip to content

Commit 4afc49e

Browse files
committed
Propagate version from fastmcp to _mcp_server, add test for clientInfo
1 parent 9724ad1 commit 4afc49e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/mcp/server/fastmcp/server.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def __init__( # noqa: PLR0913
146146
instructions: str | None = None,
147147
website_url: str | None = None,
148148
icons: list[Icon] | None = None,
149+
version: str | None = None,
149150
auth_server_provider: (OAuthAuthorizationServerProvider[Any, Any, Any] | None) = None,
150151
token_verifier: TokenVerifier | None = None,
151152
event_store: EventStore | None = None,
@@ -194,6 +195,7 @@ def __init__( # noqa: PLR0913
194195
instructions=instructions,
195196
website_url=website_url,
196197
icons=icons,
198+
version=version,
197199
# TODO(Marcelo): It seems there's a type mismatch between the lifespan type from an FastMCP and Server.
198200
# We need to create a Lifespan type that is a generic on the server type, like Starlette does.
199201
lifespan=(lifespan_wrapper(self, self.settings.lifespan) if self.settings.lifespan else default_lifespan), # type: ignore
@@ -243,6 +245,10 @@ def website_url(self) -> str | None:
243245
def icons(self) -> list[Icon] | None:
244246
return self._mcp_server.icons
245247

248+
@property
249+
def version(self) -> str | None:
250+
return self._mcp_server.version
251+
246252
@property
247253
def session_manager(self) -> StreamableHTTPSessionManager:
248254
"""Get the StreamableHTTP session manager.

tests/server/fastmcp/test_server.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
BlobResourceContents,
2222
ContentBlock,
2323
EmbeddedResource,
24+
Icon,
2425
ImageContent,
2526
TextContent,
2627
TextResourceContents,
@@ -33,9 +34,19 @@
3334
class TestServer:
3435
@pytest.mark.anyio
3536
async def test_create_server(self):
36-
mcp = FastMCP(instructions="Server instructions")
37+
mcp = FastMCP(
38+
instructions="Server instructions",
39+
website_url="https://example.com/mcp_server",
40+
version="1.0",
41+
icons=[Icon(src="https://example.com/icon.png", mimeType="image/png", sizes=["48x48", "96x96"])],
42+
)
3743
assert mcp.name == "FastMCP"
3844
assert mcp.instructions == "Server instructions"
45+
assert mcp.website_url == "https://example.com/mcp_server"
46+
assert mcp.version == "1.0"
47+
assert isinstance(mcp.icons, list)
48+
assert len(mcp.icons) == 1
49+
assert mcp.icons[0].src == "https://example.com/icon.png"
3950

4051
@pytest.mark.anyio
4152
async def test_normalize_path(self):

0 commit comments

Comments
 (0)