Add instructions field to ServerSession and FastMCP

This commit is contained in:
Salman Mohammed
2025-01-13 13:00:11 -05:00
parent 135191403a
commit bc6746e89b
6 changed files with 18 additions and 5 deletions

View File

@@ -86,9 +86,11 @@ class Settings(BaseSettings):
class FastMCP:
def __init__(self, name: str | None = None, **settings: Any):
def __init__(
self, name: str | None = None, instructions: str | None = None, **settings: Any
):
self.settings = Settings(**settings)
self._mcp_server = MCPServer(name=name or "FastMCP")
self._mcp_server = MCPServer(name=name or "FastMCP", instructions=instructions)
self._tool_manager = ToolManager(
warn_on_duplicate_tools=self.settings.warn_on_duplicate_tools
)
@@ -110,6 +112,10 @@ class FastMCP:
def name(self) -> str:
return self._mcp_server.name
@property
def instructions(self) -> str | None:
return self._mcp_server.instructions
def run(self, transport: Literal["stdio", "sse"] = "stdio") -> None:
"""Run the FastMCP server. Note this is a synchronous function.