polarity_ask
Answers natural-language questions by synthesizing relevant nodes and edges from your personal knowledge graph, providing cited sources for context-aware reasoning.
Instructions
Ask a natural-language question over the user's personal knowledge graph. Cosmos synthesizes an answer from relevant nodes and edges. Use this when the user wants context-aware reasoning rather than raw data. Returns answer text plus cited node/edge ids.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- src/tools/index.ts:42-55 (registration)Tool definition for 'polarity_ask' in the TOOLS array. Includes name, description, inputSchema (zod validation for 'query' string), and handler.
{ name: "polarity_ask", description: "Ask a natural-language question over the user's personal knowledge graph. Cosmos synthesizes an answer from relevant nodes and edges. Use this when the user wants context-aware reasoning rather than raw data. Returns answer text plus cited node/edge ids.", inputSchema: z .object({ query: z.string().min(1).max(2000), }) .strict(), handler: async (input, client) => { const { query } = input as { query: string }; return client.ask(query); }, }, - src/client/cosmos.ts:79-85 (handler)The actual handler method in CosmosClient that makes an HTTP POST to /api/polarity/ask with the polarity_user_id and query string.
ask(query: string) { return this.request<AskResponse>({ method: "POST", path: "/api/polarity/ask", body: { polarity_user_id: this.config.polarityUserId, query }, }); } - src/client/cosmos.ts:215-219 (schema)Response type for the ask endpoint, containing answer text and optional cited node/edge IDs.
export interface AskResponse { answer: string; cited_node_ids?: number[]; cited_edge_ids?: number[]; } - src/tools/index.ts:46-50 (schema)Input schema validation for polarity_ask: requires a 'query' string between 1 and 2000 characters.
inputSchema: z .object({ query: z.string().min(1).max(2000), }) .strict(), - src/server.ts:44-46 (registration)MCP CallTool handler that looks up the tool by name, validates input via Zod schema, and invokes the handler.
})); server.setRequestHandler(CallToolRequestSchema, async (req) => {