from netra import workflow, task, SpanWrapper
from mcp.server.models import Tool
from mcp.types import TextContent
@server.call_tool()
async def execute_tool(name: str, arguments: dict):
span = SpanWrapper("mcp-tool", {
"tool.name": name
}).start()
try:
result = await process_tool(name, arguments)
span.set_attribute("tool.result", str(result))
span.end()
return [TextContent(
type="text",
text=str(result)
)]
except Exception as e:
span.set_attribute("error", str(e))
span.end()
raise
@task()
async def process_tool(name: str, args: dict):
# Tool implementation
return {"status": "success"}