chore: create union for working with message content (#939)
This commit is contained in:
parent
185fa49fd1
commit
d69b290b65
3 changed files with 25 additions and 51 deletions
|
|
@ -41,14 +41,7 @@ def main(
|
|||
app = Server("mcp-streamable-http-stateless-demo")
|
||||
|
||||
@app.call_tool()
|
||||
async def call_tool(
|
||||
name: str, arguments: dict
|
||||
) -> list[
|
||||
types.TextContent
|
||||
| types.ImageContent
|
||||
| types.AudioContent
|
||||
| types.EmbeddedResource
|
||||
]:
|
||||
async def call_tool(name: str, arguments: dict) -> list[types.Content]:
|
||||
ctx = app.request_context
|
||||
interval = arguments.get("interval", 1.0)
|
||||
count = arguments.get("count", 5)
|
||||
|
|
|
|||
|
|
@ -45,14 +45,7 @@ def main(
|
|||
app = Server("mcp-streamable-http-demo")
|
||||
|
||||
@app.call_tool()
|
||||
async def call_tool(
|
||||
name: str, arguments: dict
|
||||
) -> list[
|
||||
types.TextContent
|
||||
| types.ImageContent
|
||||
| types.AudioContent
|
||||
| types.EmbeddedResource
|
||||
]:
|
||||
async def call_tool(name: str, arguments: dict) -> list[types.Content]:
|
||||
ctx = app.request_context
|
||||
interval = arguments.get("interval", 1.0)
|
||||
count = arguments.get("count", 5)
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@ from mcp.shared._httpx_utils import create_mcp_http_client
|
|||
|
||||
async def fetch_website(
|
||||
url: str,
|
||||
) -> list[
|
||||
types.TextContent | types.ImageContent | types.AudioContent | types.EmbeddedResource
|
||||
]:
|
||||
) -> list[types.Content]:
|
||||
headers = {
|
||||
"User-Agent": "MCP Test Server (github.com/modelcontextprotocol/python-sdk)"
|
||||
}
|
||||
|
|
@ -31,14 +29,7 @@ def main(port: int, transport: str) -> int:
|
|||
app = Server("mcp-website-fetcher")
|
||||
|
||||
@app.call_tool()
|
||||
async def fetch_tool(
|
||||
name: str, arguments: dict
|
||||
) -> list[
|
||||
types.TextContent
|
||||
| types.ImageContent
|
||||
| types.AudioContent
|
||||
| types.EmbeddedResource
|
||||
]:
|
||||
async def fetch_tool(name: str, arguments: dict) -> list[types.Content]:
|
||||
if name != "fetch":
|
||||
raise ValueError(f"Unknown tool: {name}")
|
||||
if "url" not in arguments:
|
||||
|
|
|
|||
Loading…
Reference in a new issue