reasoning
Performs deep reasoning to solve complex problems by analyzing questions and generating thorough solutions.
Instructions
Deep thinking and complex problem solving
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The question or problem that needs deep thinking |
Implementation Reference
- src/tools/reasoning.ts:10-63 (handler)The main handler function for the 'reasoning' tool. Sends the user's content to a DeepSeek R1 model (deepseek-r1-70b-fast-online) via the /v1/chat/completions endpoint and returns the AI response.
export async function handleReasoning(args: unknown, apiKey?: string) { if (!isValidReasoningArgs(args)) { throw new McpError( ErrorCode.InvalidParams, "Invalid reasoning arguments" ); } const { content } = args as ReasoningArgs; log("Processing reasoning request"); try { // Convert to API required format const apiRequestData = { model: "deepseek-r1-70b-fast-online", messages: [ { role: "user", content: content } ], stream: false }; const response = await makeRequest<ReasoningResponse>( API_CONFIG.ENDPOINTS.REASONING, apiRequestData, apiKey ); // Directly use the correct structure of ReasoningResponse const resultText = response.choices && response.choices.length > 0 ? response.choices[0].message.content : JSON.stringify(response); return { content: [{ type: "text", mimeType: "text/plain", text: resultText }] }; } catch (error) { log("Reasoning API error:", error); return { content: [{ type: "text", mimeType: "text/plain", text: `Reasoning API error: ${formatError(error)}` }], isError: true }; } } - src/types.ts:242-244 (schema)TypeScript interface for the reasoning tool arguments (content: string).
export interface ReasoningArgs { content: string; } - src/types.ts:246-255 (schema)TypeScript interface for the reasoning API response (choices with message content).
export interface ReasoningResponse { choices: [{ message: { content: string; role: string; }; finish_reason: string; index: number; }]; } - src/types.ts:257-269 (schema)Type guard function that validates reasoning arguments (checks content is a non-empty string).
export function isValidReasoningArgs(args: unknown): args is ReasoningArgs { if (typeof args !== 'object' || args === null) { return false; } const { content } = args as ReasoningArgs; if (typeof content !== 'string' || content.trim().length === 0) { return false; } return true; } - src/tools/index.ts:141-155 (registration)Registration of the 'reasoning' tool with name, description, and inputSchema (requires string content).
// Reasoning tool definition export const REASONING_TOOL: Tool = { name: "reasoning", description: "Deep thinking and complex problem solving", inputSchema: { type: "object", properties: { content: { type: "string", description: "The question or problem that needs deep thinking" } }, required: ["content"] } }; - src/tools/index.ts:180-188 (registration)Export of ALL_TOOLS array which includes REASONING_TOOL.
// Export all tools export const ALL_TOOLS = [ SEARCH_TOOL, NEWS_TOOL, CRAWL_TOOL, SITEMAP_TOOL, REASONING_TOOL, TRENDING_TOOL ]; - src/tools/handlers.ts:34-35 (registration)Dispatch in handleToolCall that routes REASONING_TOOL.name to handleReasoning.
case REASONING_TOOL.name: return await handleReasoning(args, apiKey); - src/config.ts:42-49 (helper)API endpoint configuration for REASONING (/v1/chat/completions) on the search1api base URL.
ENDPOINTS: { SEARCH: '/search', CRAWL: '/crawl', SITEMAP: '/sitemap', NEWS: '/news', REASONING: '/v1/chat/completions', TRENDING: '/trending' }