FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(server): restore `dependencies` parameter on MCPServer by maxisbey · Pull Request #2358 · modelcontextprotocol/python-sdk · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 6 additions & 0 deletions src/mcp/server/mcpserver/server.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ class Settings(BaseSettings, Generic[LifespanResultT]):
# prompt settings
warn_on_duplicate_prompts: bool

dependencies: list[str]
"""List of dependencies to install in the server environment. Used by the `mcp install` and `mcp dev` CLI."""

lifespan: Callable[[MCPServer[LifespanResultT]], AbstractAsyncContextManager[LifespanResultT]] | None
"""An async context manager that will be called when the server is started."""

Expand Down Expand Up @@ -142,6 +145,7 @@ def __init__(
warn_on_duplicate_resources: bool = True,
warn_on_duplicate_tools: bool = True,
warn_on_duplicate_prompts: bool = True,
dependencies: list[str] | None = None,
lifespan: Callable[[MCPServer[LifespanResultT]], AbstractAsyncContextManager[LifespanResultT]] | None = None,
auth: AuthSettings | None = None,
):
Expand All @@ -151,9 +155,11 @@ def __init__(
warn_on_duplicate_resources=warn_on_duplicate_resources,
warn_on_duplicate_tools=warn_on_duplicate_tools,
warn_on_duplicate_prompts=warn_on_duplicate_prompts,
dependencies=dependencies or [],
lifespan=lifespan,
auth=auth,
)
self.dependencies = self.settings.dependencies

self._tool_manager = ToolManager(tools=tools, warn_on_duplicate_tools=self.settings.warn_on_duplicate_tools)
self._resource_manager = ResourceManager(warn_on_duplicate_resources=self.settings.warn_on_duplicate_resources)
Expand Down
9 changes: 9 additions & 0 deletions tests/server/mcpserver/test_server.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ async def test_create_server(self):
assert len(mcp.icons) == 1
assert mcp.icons[0].src == "https://example.com/icon.png"

def test_dependencies(self):
"""Dependencies list is read by `mcp install` / `mcp dev` CLI commands."""
mcp = MCPServer("test", dependencies=["pandas", "numpy"])
assert mcp.dependencies == ["pandas", "numpy"]
assert mcp.settings.dependencies == ["pandas", "numpy"]

mcp_no_deps = MCPServer("test")
assert mcp_no_deps.dependencies == []

async def test_sse_app_returns_starlette_app(self):
"""Test that sse_app returns a Starlette application with correct routes."""
mcp = MCPServer("test")
Expand Down
Loading

Back | FazBrowse Home | New Git URL