Add title to tools, resources, prompts (#972)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Felix Weinberger 2025-06-17 10:53:14 -04:00 • committed by GitHub
commit a2f8766a8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 481 additions and 46 deletions

View file

@ -53,6 +53,7 @@ def main(port: int, transport: str) -> int:
return [
types.Prompt(
name="simple",
title="Simple Assistant Prompt",
description="A simple prompt that can take optional context and topic "
"arguments",
arguments=[

View file

@ -5,9 +5,18 @@ from mcp.server.lowlevel import Server
from pydantic import AnyUrl, FileUrl
SAMPLE_RESOURCES = {
"greeting": "Hello! This is a sample text resource.",
"help": "This server provides a few sample text resources for testing.",
"about": "This is the simple-resource MCP server implementation.",
"greeting": {
"content": "Hello! This is a sample text resource.",
"title": "Welcome Message",
},
"help": {
"content": "This server provides a few sample text resources for testing.",
"title": "Help Documentation",
},
"about": {
"content": "This is the simple-resource MCP server implementation.",
"title": "About This Server",
},
}
@ -28,6 +37,7 @@ def main(port: int, transport: str) -> int:
types.Resource(
uri=FileUrl(f"file:///{name}.txt"),
name=name,
title=SAMPLE_RESOURCES[name]["title"],
description=f"A sample text resource named {name}",
mimeType="text/plain",
)
@ -43,7 +53,7 @@ def main(port: int, transport: str) -> int:
if name not in SAMPLE_RESOURCES:
raise ValueError(f"Unknown resource: {uri}")
return SAMPLE_RESOURCES[name]
return SAMPLE_RESOURCES[name]["content"]
if transport == "sse":
from mcp.server.sse import SseServerTransport

View file

@ -41,6 +41,7 @@ def main(port: int, transport: str) -> int:
return [
types.Tool(
name="fetch",
title="Website Fetcher",
description="Fetches a website and returns its content",
inputSchema={
"type": "object",