8000 feature request: Enable mcp-client to call addMcpServer via RPC within a Durable Object Agent · Issue #293 · cloudflare/agents · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
feature request: Enable mcp-client to call addMcpServer via RPC within a Durable Object Agent #293
Closed
@arre-ankit

Description

@arre-ankit

I'm working with the new Agent framework and building an MCP client by extending the Agent class within a Durable Object, something like this:

export class MCP extends Agent<Env, never> {
  mcp = new MCPClientManager("my-agent", "1.0.0");

  async fetch(request: Request) {
    return (
      (await routeAgentRequest(request, this.env, { cors: true })) ||
      new Response("Not found", { status: 404 })
    );
  }

  async onRequest(request: Request): Promise<Response> {
    const reqUrl = new URL(request.url);
    if (reqUrl.pathname.endsWith("add-mcp") && request.method === "POST") {
      await this.addMcpServer("Slack", "http://localhost:8000/sse", "http://localhost:8787");
      return new Response("Ok", { status: 200 });
    }

    return new Response("Not found", { status: 404 });
  }

  async listTools() {
    return this.mcp.listTools();
  }

  async getServerId() {
    const tools = await this.mcp.listTools();
    return tools[0].serverId;
  }

  async callTool(toolName: string, args?: { [x: string]: unknown }) {
    return this.mcp.callTool({
      name: toolName,
      serverId: await this.getServerId(),
      arguments: args
    });
  }
}

I want to call the addMcpServer method from my Hono route (i.e., remotely invoke it via RPC).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0