Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/mcp/server/fastmcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def __init__( # noqa: PLR0913
instructions: str | None = None,
website_url: str | None = None,
icons: list[Icon] | None = None,
version: str | None = None,
auth_server_provider: (OAuthAuthorizationServerProvider[Any, Any, Any] | None) = None,
token_verifier: TokenVerifier | None = None,
event_store: EventStore | None = None,
Expand Down Expand Up @@ -194,6 +195,7 @@ def __init__( # noqa: PLR0913
instructions=instructions,
website_url=website_url,
icons=icons,
version=version,
# TODO(Marcelo): It seems there's a type mismatch between the lifespan type from an FastMCP and Server.
# We need to create a Lifespan type that is a generic on the server type, like Starlette does.
lifespan=(lifespan_wrapper(self, self.settings.lifespan) if self.settings.lifespan else default_lifespan), # type: ignore
Expand Down Expand Up @@ -243,6 +245,10 @@ def website_url(self) -> str | None:
def icons(self) -> list[Icon] | None:
return self._mcp_server.icons

@property
def version(self) -> str | None:
return self._mcp_server.version

@property
def session_manager(self) -> StreamableHTTPSessionManager:
"""Get the StreamableHTTP session manager.
Expand Down
13 changes: 12 additions & 1 deletion tests/server/fastmcp/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
BlobResourceContents,
ContentBlock,
EmbeddedResource,
Icon,
ImageContent,
TextContent,
TextResourceContents,
Expand All @@ -33,9 +34,19 @@
class TestServer:
@pytest.mark.anyio
async def test_create_server(self):
mcp = FastMCP(instructions="Server instructions")
mcp = FastMCP(
instructions="Server instructions",
website_url="https://example.com/mcp_server",
version="1.0",
icons=[Icon(src="https://example.com/icon.png", mimeType="image/png", sizes=["48x48", "96x96"])],
)
assert mcp.name == "FastMCP"
assert mcp.instructions == "Server instructions"
assert mcp.website_url == "https://example.com/mcp_server"
assert mcp.version == "1.0"
assert isinstance(mcp.icons, list)
assert len(mcp.icons) == 1
assert mcp.icons[0].src == "https://example.com/icon.png"

@pytest.mark.anyio
async def test_normalize_path(self):
Expand Down