Skip to content

Commit b657795

Browse files
authored
feat: tools dump (#199)
expose required internal functions, hide non-required fields from tools list
1 parent a48aa0a commit b657795

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/index-internals.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
*/
44

55
import { defaults, HelperTools } from './const.js';
6-
import { parseInputParamsFromUrl } from './mcp/utils.js';
7-
import { addRemoveTools, defaultTools, toolCategories, toolCategoriesEnabledByDefault } from './tools/index.js';
6+
import { parseInputParamsFromUrl, processParamsGetTools } from './mcp/utils.js';
7+
import { addRemoveTools, defaultTools, getActorsAsTools, toolCategories, toolCategoriesEnabledByDefault } from './tools/index.js';
88
import { actorNameToToolName } from './tools/utils.js';
99
import type { ToolCategory } from './types.js';
10+
import { getToolPublicFieldOnly } from './utils/tools.js';
1011

1112
export {
1213
parseInputParamsFromUrl,
@@ -18,4 +19,7 @@ export {
1819
toolCategories,
1920
toolCategoriesEnabledByDefault,
2021
type ToolCategory,
22+
processParamsGetTools,
23+
getActorsAsTools,
24+
getToolPublicFieldOnly,
2125
};

src/mcp/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { addRemoveTools, callActorGetDataset, defaultTools, getActorsAsTools, to
3030
import { actorNameToToolName, decodeDotPropertyNames } from '../tools/utils.js';
3131
import type { ActorMcpTool, ActorTool, HelperTool, ToolEntry } from '../types.js';
3232
import { createProgressTracker } from '../utils/progress.js';
33+
import { getToolPublicFieldOnly } from '../utils/tools.js';
3334
import { connectMCPClient } from './client.js';
3435
import { EXTERNAL_TOOL_CALL_TIMEOUT_MSEC } from './const.js';
3536
import { processParamsGetTools } from './utils.js';
@@ -390,7 +391,7 @@ export class ActorsMcpServer {
390391
* @returns {object} - The response object containing the tools.
391392
*/
392393
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
393-
const tools = Array.from(this.tools.values()).map((tool) => (tool.tool));
394+
const tools = Array.from(this.tools.values()).map((tool) => getToolPublicFieldOnly(tool.tool));
394395
return { tools };
395396
});
396397

src/utils/tools.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { ToolBase } from '../types.js';
2+
3+
/**
4+
* Returns a public version of the tool containing only fields that should be exposed publicly.
5+
* Used for the tools list request.
6+
*/
7+
export function getToolPublicFieldOnly(tool: ToolBase) {
8+
return {
9+
name: tool.name,
10+
description: tool.description,
11+
inputSchema: tool.inputSchema,
12+
};
13+
}

0 commit comments

Comments
 (0)