4949from mcp .types import Resource as MCPResource
5050from mcp .types import ResourceTemplate as MCPResourceTemplate
5151from mcp .types import Tool as MCPTool
52+ from mcp .types import ServerInfo
5253
5354logger = get_logger (__name__ )
5455
@@ -177,7 +178,7 @@ async def _run(self, transport: Literal["stdio", "sse"]):
177178 else : # transport == "sse"
178179 await self .run_sse_async ()
179180
180- async def get_server_info (self ):
181+ async def get_server_info (self ) -> ServerInfo :
181182 """
182183 Asynchronously retrieves and returns server information.
183184
@@ -196,18 +197,18 @@ async def get_server_info(self):
196197 - prompts (list): A list of prompts available on the server.
197198 - resource_templates (list): A list of resource templates available on the server.
198199 """
199- return {
200- ' name' : self .name ,
201- ' host' : self .settings .host ,
202- ' port' : self .settings .port ,
203- ' instructions' : self .instructions ,
204- ' assets' : {
205- ' tools' : await self .list_tools (),
206- ' resources' : await self .list_resources (),
207- ' prompts' : await self .list_prompts (),
208- ' resource_templates' : await self .list_resource_templates ()
209- }
210- }
200+ return ServerInfo (
201+ name = self .name ,
202+ host = self .settings .host ,
203+ port = self .settings .port ,
204+ instructions = self .instructions ,
205+ assets = ServerInfo . ServerInfoAssets (
206+ tools = await self .list_tools (),
207+ resources = await self .list_resources (),
208+ prompts = await self .list_prompts (),
209+ resource_templates = await self .list_resource_templates ()
210+ )
211+ )
211212
212213 def _setup_handlers (self ) -> None :
213214 """Set up core MCP protocol handlers."""
0 commit comments