This is a Model Context Protocol (MCP) server that provides a flexible and configurable two-stage reasoning and response generation system. It's a fork of the original Deepseek-Thinking-Claude-3.5-Sonnet-CLINE-MCP project, significantly expanding its capabilities by supporting multiple AI providers and models for both reasoning and coding/response generation.
The original project was specifically designed to use DeepSeek R1 for reasoning and Claude 3.5 Sonnet for response generation, both accessed exclusively through OpenRouter. This fork generalizes the architecture to support a wider range of providers and models. Here's a breakdown of the key differences:
-
Multi-Provider Support: Instead of being locked into OpenRouter, this fork can now use:
- OpenRouter
- OpenAI
- Anthropic (Claude)
- DeepSeek
- Google Gemini
- Google Vertex AI
-
Configurable Reasoning and Coding Models: The original hardcoded DeepSeek for reasoning and Claude for the final response. This fork allows you to configure both the reasoning and coding/response generation models independently. You can mix and match providers. For example, you could use Gemini for reasoning and OpenAI for the final response.
-
providers.json
Configuration: A newproviders.json
file is introduced to manage the available models and their specific parameters (temperature, top_p, etc.) for each provider. This makes it easy to add new models or tweak existing ones without modifying the core code. -
Environment Variable Configuration: The choice of reasoning and coding providers/models is now primarily controlled through environment variables:
REASONING_PROVIDER
: Specifies the provider for the reasoning stage (e.g.,openai
,gemini
,deepseek
,openrouter
,anthropic
,vertex
).REASONING_MODEL
: Specifies the model to use for reasoning (e.g.,gpt-4
,gemini-pro
,deepseek/deepseek-r1
).CODING_PROVIDER
: Specifies the provider for the coding/response generation stage.CODING_MODEL
: Specifies the model for the final response.
-
Dynamic Client Initialization: The code now dynamically initializes only the necessary API clients based on the
REASONING_PROVIDER
andCODING_PROVIDER
settings. This avoids unnecessary initialization and dependencies. -
Unified
getReasoning
andgetFinalResponse
: The provider-specific logic is abstracted intogetReasoning
andgetFinalResponse
functions, making the core task processing logic provider-agnostic. -
Retains core MCP structure: The fork retains the core structure of using MCP, so it will integrate with any MCP client, like the original implementation. It defines the
generate_response
andcheck_response_status
tools in the same way. -
Retains Cline integration: Like the original, the fork is intended for integration with Cline, the Claude Desktop extension.
-
Retains Conversation History Feature: The forked implementation has kept the feature of using the conversation history of Cline for context.
-
No Hardcoded Models: There are no hardcoded models in the new implementation, the models are defined in the .env file and providers.json
-
Two-Stage Processing:
- Uses a configurable model for initial reasoning (e.g., DeepSeek, GPT-4, Gemini Pro).
- Uses a configurable model for final response/code generation (e.g., Claude, GPT-4, DeepSeek Chat).
- Injects the reasoning from the first stage into the context of the second stage.
-
Flexible Provider and Model Selection:
- Choose from OpenRouter, OpenAI, Anthropic, DeepSeek, Gemini, and Vertex AI for both reasoning and coding stages.
- Easily configure models and their parameters via
providers.json
and environment variables.
-
Smart Conversation Management (Inherited from Original):
- Detects active Cline conversations using file modification times.
- Handles multiple concurrent conversations.
- Filters out ended conversations automatically.
- Supports context clearing.
-
Optimized Parameters (Configurable):
- Model-specific context limits are respected (e.g., 50,000 characters for DeepSeek reasoning, larger limits for response models).
- Parameters like
temperature
,top_p
, andrepetition_penalty
are configurable per model inproviders.json
.
-
Response Polling (Inherited from Original):
- Uses a polling mechanism with
generate_response
(to get a task ID) andcheck_response_status
(to check the status). This handles the asynchronous nature of LLM calls.
- Uses a polling mechanism with
To install Reasoning-Coder for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @mario-andreschak/mcp-reasoning-coding --client claude
-
Clone this repository:
git clone https://github.com/mario-andreschak/mcp-reasoning-coding.git cd /mcp-reasoning-coding
-
Install Dependencies:
npm install
-
Create a
.env
File: This file will hold your API keys and provider/model selections. Example:# --- Required API Keys (at least one) --- OPENROUTER_API_KEY=your_openrouter_key OPENAI_API_KEY=your_openai_key ANTHROPIC_API_KEY=your_anthropic_key DEEPSEEK_API_KEY=your_deepseek_key GEMINI_API_KEY=your_gemini_key VERTEX_PROJECT_ID=your_vertex_project_id # For Vertex AI VERTEX_REGION=your_vertex_region # For Vertex AI # --- Provider and Model Selection --- REASONING_PROVIDER=openrouter REASONING_MODEL=deepseek/deepseek-r1 CODING_PROVIDER=openrouter CODING_MODEL=anthropic/claude-3.5-sonnet:beta
Important: You only need to provide API keys for the providers you intend to use. If you're only using OpenAI, you don't need an
OPENROUTER_API_KEY
, for example. -
providers.json
File: This file defines the available models for each provider and their parameters. Place this file in thesrc
folder. Example (src/providers.json
):{ "openrouter": { "deepseek/deepseek-r1": { "temperature": 0.7, "top_p": 1 }, "anthropic/claude-3.5-sonnet:beta": { "temperature": 0.7, "top_p": 1, "repetition_penalty": 1 }, "deepseek/deepseek-chat":{ "temperature": 0.7, "top_p": 1 } }, "openai": { "gpt-4": { "temperature": 0.7, "top_p": 1 }, "gpt-3.5-turbo": { "temperature": 0.7, "top_p": 1 } }, "anthropic": { "claude-3-opus-20240229": { "temperature": 0.7, "top_p": 1 } }, "deepseek": { "deepseek-coder": { "temperature": 0.7, "top_p": 1 } }, "gemini":{ "gemini-pro":{ } }, "vertex": { "gemini-1.5-pro-002":{ } } }
extra_params
: You can add provider-specific parameters within the model definition using theextra_params
key. Consult the API documentation for each provider to see what options are available.
-
Build the server:
npm run build
Add to your Cline MCP settings (usually in ~/.vscode/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
):
{
"mcpServers": {
"reasoning-coding": {
"command": "/path/to/node",
"args": ["/path/to/your-fork/build/index.js"], // Adjust path
"env": {
// Your .env variables will be inherited, so no need to duplicate them here
},
"disabled": false,
"autoApprove": []
}
}
}
Replace /path/to/node
and /path/to/your-fork/build/index.js
with the correct paths.
The server provides the same two tools as the original:
Generates a response using the configured reasoning and coding models.
{
"prompt": string, // Required: The question or prompt
"showReasoning"?: boolean, // Optional: Show the reasoning process
"clearContext"?: boolean, // Optional: Clear conversation history
"includeHistory"?: boolean // Optional: Include Cline conversation history
}
Checks the status of a response generation task.
{
"taskId": string // Required: The task ID from generate_response
}
-
Initial Request: Call
generate_response
to get ataskId
.const result = await use_mcp_tool({ server_name: "reasoning-coding", tool_name: "generate_response", arguments: { prompt: "Explain the theory of relativity.", showReasoning: true } }); const taskId = JSON.parse(result.content[0].text).taskId;
-
Status Checking: Poll
check_response_status
with thetaskId
until the status iscomplete
(orerror
).const status = await use_mcp_tool({ server_name: "reasoning-coding", tool_name: "check_response_status", arguments: { taskId } }); // Example status response when complete: { "status": "complete", "reasoning": "...", // If showReasoning was true "response": "..." // The final response "error": undefined // Will have a value if an error occurred }
For development with auto-rebuild:
npm run watch
-
Reasoning Stage:
- The
getReasoning
function is called with the user's prompt (and potentially Cline conversation history). - Based on the
REASONING_PROVIDER
environment variable, the appropriate provider-specific function (e.g.,getReasoningOpenAI
,getReasoningGemini
) is called. - The selected model (from
REASONING_MODEL
) is used to generate the reasoning. - The reasoning is returned.
- The
-
Response Stage:
- The
getFinalResponse
function is called with the original prompt and the reasoning from the first stage. - Based on the
CODING_PROVIDER
environment variable, the appropriate provider-specific function is called. - The selected model (from
CODING_MODEL
) generates the final response, incorporating the reasoning. - The response is returned.
- The
-
MCP Handling: The
ReasoningCodingServer
class handles the MCP communication, task management, and context management. It uses thegetReasoning
andgetFinalResponse
functions to orchestrate the two-stage process.
MIT License - See LICENSE file for details.
- Based on the original Deepseek-Thinking-Claude-3.5-Sonnet-CLINE-MCP project.
- Inspired by the RAT (Retrieval Augmented Thinking) concept by Skirano.
Key improvements in this README:
* **Clearer Title:** A more descriptive title reflects the expanded functionality.
* **Detailed Comparison:** A dedicated section highlights the differences between the fork and the original.
* **Comprehensive Installation:** Instructions are more thorough, covering `.env` and `providers.json` setup.
* **Provider/Model Explanation:** The roles of environment variables and `providers.json` are clearly explained.
* **Example `providers.json`:** A complete example helps users get started.
* **Updated Usage:** Reflects the new server name and configuration.
* **Expanded "How It Works":** Provides a more detailed explanation of the internal workings.
* **Corrected filepaths:** Uses correct filepaths to the providers file