in gremlin-mcp/src/main/javascript/src/handlers/tools.ts [65:147]
export function registerEffectToolHandlers(
server: McpServer,
runtime: Runtime.Runtime<GremlinService>
): void {
// Get Graph Status
server.registerTool(
TOOL_NAMES.GET_GRAPH_STATUS,
{
title: 'Get Graph Status',
description: 'Get the connection status of the Gremlin graph database',
inputSchema: emptyInputSchema.shape,
},
() =>
Effect.runPromise(
pipe(
createStringToolEffect(
Effect.andThen(GremlinService, service =>
Effect.map(service.getStatus, statusObj => statusObj.status)
),
'Connection status check failed'
),
Effect.provide(runtime)
)
)
);
// Get Graph Schema
server.registerTool(
TOOL_NAMES.GET_GRAPH_SCHEMA,
{
title: 'Get Graph Schema',
description:
'Get the complete schema of the graph including vertex labels, edge labels, and relationship patterns',
inputSchema: emptyInputSchema.shape,
},
() =>
Effect.runPromise(
pipe(
createToolEffect(
Effect.andThen(GremlinService, service => service.getSchema),
'Schema retrieval failed'
),
Effect.provide(runtime)
)
)
);
// Refresh Schema Cache
server.registerTool(
TOOL_NAMES.REFRESH_SCHEMA_CACHE,
{
title: 'Refresh Schema Cache',
description: 'Force an immediate refresh of the graph schema cache',
inputSchema: emptyInputSchema.shape,
},
() =>
Effect.runPromise(
pipe(
createStringToolEffect(
Effect.andThen(GremlinService, service =>
Effect.map(service.refreshSchemaCache, () => 'Schema cache refreshed successfully.')
),
'Failed to refresh schema'
),
Effect.provide(runtime)
)
)
);
// Run Gremlin Query
server.registerTool(
TOOL_NAMES.RUN_GREMLIN_QUERY,
{
title: 'Run Gremlin Query',
description: 'Execute a Gremlin traversal query against the graph database',
inputSchema: runQueryInputSchema.shape,
},
(args: unknown) => {
const { query } = runQueryInputSchema.parse(args);
return Effect.runPromise(pipe(createQueryEffect(query), Effect.provide(runtime)));
}
);
}