Add a pluggable server extension API with MCP Apps (#3003)
Co-authored-by: Max Isbey <224885523+maxisbey@users.noreply.github.com>
This commit is contained in:
parent
fe9723853d
commit
4b519782f1
1 changed files with 2598 additions and 24 deletions
20
docs_src/apps/tutorial003.py
Normal file
20
docs_src/apps/tutorial003.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from pathlib import Path
|
||||
|
||||
from mcp.server.apps import Apps
|
||||
from mcp.server.mcpserver import MCPServer
|
||||
from mcp.server.mcpserver.resources import FileResource
|
||||
|
||||
REPORT_HTML = Path(__file__).parent / "report.html"
|
||||
|
||||
apps = Apps()
|
||||
|
||||
|
||||
@apps.tool(resource_uri="ui://report/app.html")
|
||||
def refresh_report() -> str:
|
||||
"""Refresh the report data."""
|
||||
return "report refreshed"
|
||||
|
||||
|
||||
apps.add_resource(FileResource(uri="ui://report/app.html", name="report", path=REPORT_HTML))
|
||||
|
||||
mcp = MCPServer("report", extensions=[apps])
|
||||
Loading…
Reference in a new issue