MCPcopy Index your code
hub / github.com/callstack/agent-device / createCommandToolExecutor

Function createCommandToolExecutor

src/mcp/command-tools.ts:60–88  ·  view source on GitHub ↗
(deps: CommandToolExecutorDeps = {})

Source from the content-addressed store, hash-verified

58}
59
60export function createCommandToolExecutor(deps: CommandToolExecutorDeps = {}): CommandToolExecutor {
61 return {
62 execute: async (name, input) => {
63 if (!isCommandName(name)) {
64 throw new Error(`Unknown command tool: ${name}`);
65 }
66 const config = readMcpToolConfig(input);
67 const commandInput = stripMcpConfigFields(input);
68 const client = await createClient(deps, config.client);
69 const result = await (deps.runCommand ?? runCommand)(client, name, commandInput);
70 return {
71 isError: false,
72 structuredContent: result,
73 content: [
74 {
75 type: 'text',
76 text: renderToolText({
77 name,
78 input: commandInput,
79 result,
80 outputFormat: config.outputFormat,
81 responseLevel: config.client.responseLevel,
82 }),
83 },
84 ],
85 };
86 },
87 };
88}
89
90export const commandToolExecutor = createCommandToolExecutor();
91

Callers 2

command-tools.tsFile · 0.85

Calls 5

isCommandNameFunction · 0.90
readMcpToolConfigFunction · 0.85
stripMcpConfigFieldsFunction · 0.85
createClientFunction · 0.85
renderToolTextFunction · 0.85

Tested by

no test coverage detected