Skip to content

Commit 3543a5e

Browse files
committed
fix proxy tool name handling
1 parent b8b3ce3 commit 3543a5e

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

src/mcp/const.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22
export const MAX_TOOL_NAME_LENGTH = 64;
3-
export const SERVER_ID_LENGTH = 16
3+
export const SERVER_ID_LENGTH = 8

src/mcp/mcp-server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export class ActorsMcpServer {
6363
/**
6464
* Loads tools from URL params.
6565
*
66+
* This method also handles enabling of Actor auto loading via the processParamsGetTools.
67+
*
6668
* Used primarily for SSE.
6769
*/
6870
public async loadToolsFromUrl(url: string, apifyToken: string) {
@@ -165,7 +167,7 @@ export class ActorsMcpServer {
165167
try {
166168
client = await createMCPClient(serverTool.serverUrl, apifyToken);
167169
const res = await client.callTool({
168-
name: name,
170+
name: serverTool.originToolName,
169171
arguments: args,
170172
});
171173

src/mcp/proxy.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Ajv from "ajv";
22
import { ActorMCPTool, ToolWrap } from "../types";
33
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
4-
import { getMCPServerID } from "./utils";
4+
import { getMCPServerID, getProxyMCPServerToolName } from "./utils";
55

66
export async function getMCPServerTools(
77
actorID: string,
@@ -21,7 +21,9 @@ export async function getMCPServerTools(
2121
actorID,
2222
serverId: getMCPServerID(serverUrl),
2323
serverUrl,
24-
name: tool.name,
24+
originToolName: tool.name,
25+
26+
name: getProxyMCPServerToolName(serverUrl, tool.name),
2527
description: tool.description || "",
2628
inputSchema: tool.inputSchema,
2729
ajvValidate: ajv.compile(tool.inputSchema)

src/mcp/utils.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import type { ToolWrap } from '../types.js';
88

99
import { addTool, getActorsAsTools, removeTool } from '../tools/index.js';
1010
import { Input } from "../types.js";
11-
import { getActorsMCPServerURL, isActorMCPServer } from "./actors";
12-
import { getMCPServerTools } from "./proxy";
13-
import { createMCPClient } from "./client";
1411

1512
/**
1613
* Generates a unique server ID based on the provided URL.
@@ -32,7 +29,7 @@ export function getMCPServerID(url: string): string {
3229
* @param toolName The tool name to generate the tool name from.
3330
* @returns A unique tool name.
3431
*/
35-
export function getServerToolName(url: string, toolName: string): string {
32+
export function getProxyMCPServerToolName(url: string, toolName: string): string {
3633
const prefix = getMCPServerID(url);
3734

3835
const fullName = `${prefix}-${toolName}`;

src/types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,16 @@ export interface HelperTool extends ToolBase {
106106
* Extends ToolBase with tool associated MCP server.
107107
*/
108108
export interface ActorMCPTool extends ToolBase {
109+
// Origin MCP server tool name, is needed for the tool call
110+
originToolName: string;
109111
// ID of the Actorized MCP server
110112
actorID: string;
111-
// Name of the Actorized MCP server the tool is associated with
113+
/**
114+
* ID of the Actorized MCP server the tool is associated with.
115+
* See getMCPServerID()
116+
*/
112117
serverId: string;
118+
// Connection URL of the Actorized MCP server
113119
serverUrl: string;
114120
}
115121

0 commit comments

Comments
 (0)