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

Function createMemberToolHandler

server/src/mcp/exposed-tools.ts:145–172  ·  view source on GitHub ↗
(toolName: string)

Source from the content-addressed store, hash-verified

143 * callers receive an error with isError: true.
144 */
145export function createMemberToolHandler(toolName: string) {
146 return async (
147 args: Record<string, unknown>,
148 authContext?: MCPAuthContext,
149 ): Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean }> => {
150 if (!authContext || authContext.sub === 'anonymous') {
151 return {
152 content: [{ type: 'text', text: 'Authentication required. Connect with OAuth to use this tool.' }],
153 isError: true,
154 };
155 }
156
157 const memberContext = mcpAuthToMemberContext(authContext);
158 const handlers = createMemberToolHandlers(memberContext);
159 const handler = handlers.get(toolName);
160
161 if (!handler) {
162 logger.error({ toolName }, 'Member tool handler not found');
163 return {
164 content: [{ type: 'text', text: JSON.stringify({ error: `Unknown tool: ${toolName}` }) }],
165 isError: true,
166 };
167 }
168
169 const result = await handler(args);
170 return { content: [{ type: 'text', text: result }] };
171 };
172}
173
174/**
175 * Create handlers for stateless tools (schema and property validation).

Callers 2

createAllHandlersFunction · 0.85

Calls 4

mcpAuthToMemberContextFunction · 0.85
createMemberToolHandlersFunction · 0.85
handlerFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected