MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / call

Function call

server/tests/unit/training-agent-idempotency.test.ts:30–47  ·  view source on GitHub ↗
(
  server: ReturnType<typeof createTrainingAgentServer>,
  toolName: string,
  args: Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

28const BRAND = { domain: 'idem-test.example' };
29
30async function call(
31 server: ReturnType<typeof createTrainingAgentServer>,
32 toolName: string,
33 args: Record<string, unknown>,
34): Promise<{ parsed: Record<string, unknown>; isError?: boolean }> {
35 const requestHandlers = (server as any)._requestHandlers as Map<string, Function>;
36 const handler = requestHandlers.get('tools/call');
37 if (!handler) throw new Error('CallTool handler not found');
38 const response = await handler(
39 { method: 'tools/call', params: { name: toolName, arguments: args } },
40 {},
41 );
42 const text = response.content?.[0]?.text;
43 const parsed: Record<string, unknown> = response.structuredContent
44 ? (response.structuredContent as Record<string, unknown>)
45 : (text ? JSON.parse(text) : {});
46 return { parsed, isError: response.isError };
47}
48
49const basePayload = () => ({
50 account: ACCOUNT,

Calls 2

handlerFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected