Claude_Desktop_Bridge_via_MCP
Implement a middleware communication proxy (MCP) to link the local Claude Desktop application with the external Anthropic API, enabling access to extended context lengths, user-defined initialization directives, and sophisticated dialogue state maintenance. This infrastructure facilitates smooth toggling between standard local client functionality and advanced API capabilities.
Author

mlobo2012
Quick Info
Actions
Tags
Bridging Claude Desktop to Anthropic API using an MCP Server
This repository furnishes an MCP (Messaging Control Protocol) server implementation designed for seamless interoperability between the Claude Desktop client and the full Claude Web API. This abstraction layer allows users to circumvent inherent limitations of the standard Professional Tier subscription, unlocking features such as vastly expanded context windows, programmatic system prompt injection, and robust session handling.
Core Capabilities
- Direct, authenticated communication channel to the Claude API through MCP.
- Persistent tracking and manipulation of ongoing conversation threads.
- Dedicated support for injecting custom initialization messages (system prompts).
- Effortless transition mechanism between native Desktop operation and API-backed operations.
- Simplified configuration accessible via the Claude Desktop interface.
Selection Criteria
- Standard Desktop Plan (Default operational mode):
- Routine conversational tasks within the application interface.
- Utilization adhering strictly to subscription constraints.
-
Zero supplementary setup required.
-
External API Access (Activated via this MCP proxy):
- When processing requirements exceed standard context boundaries.
- For deploying unique behavioral constraints via system prompts.
- To circumvent imposed request frequency limitations (rate limits).
- For complex stateful dialogue management across extended interactions.
Deployment Procedure
- Acquire the Source Code bash # For VS Code users: # 1. Invoke Cmd + Shift + P # 2. Input the command: "Git: Clone" # 3. Paste the repository URL: https://github.com/mlobo2012/Claude_Desktop_API_USE_VIA_MCP.git
# Alternatively, using the terminal shell: git clone https://github.com/mlobo2012/Claude_Desktop_API_USE_VIA_MCP.git cd Claude_Desktop_API_USE_VIA_MCP
-
Dependency Installation bash pip install -r requirements.txt
-
Environment Variable Setup bash # Copy the template file cp .env.example .env
# Modify .env to include your secret key ANTHROPIC_API_KEY=your_secure_api_key_here
- Claude Desktop Configuration Adjustment
-
macOS Users: Navigate to the system support directory: bash # Use Finder's 'Go to Folder' (Cmd + Shift + G) # Enter path: ~/Library/Application Support/Claude/
-
Windows Users: Access the roaming application data path: bash # Enter path: %APPDATA%\Claude\
-
Locate or generate the configuration file named
claude_desktop_config.json. - Transfer the structural content from the repository's
config/claude_desktop_config.jsoninto your local file. - Ensure all necessary path pointers and the retrieved API key are correctly referenced.
Operational Guide
Standard Interaction
- Native Client Use
- Engage with Claude normally through the desktop interface.
- This defaults to utilizing your existing paid subscription tier.
-
No specialized invocation syntax is required.
-
Forcing API Dispatch
@claude-api Execute this task via the external API: Detail the process of photosynthesis.
Advanced Feature Invocation
- Applying Custom Directives
@claude-api {"system_prompt": "You are a highly critical code reviewer focused solely on security flaws"} Review the following snippet
- Session State Management
# Initiate a new, separately tracked dialogue thread @claude-api {"conversation_id": "security_audit_2024"} Begin our review of the authentication module
# Continue the previously started thread @claude-api {"conversation_id": "security_audit_2024"} What are the risks associated with session fixation?
# Request transcript retrieval @claude-api get_conversation_history security_audit_2024
# Terminate and purge the dialogue thread @claude-api clear_conversation security_audit_2024
Financial Oversight
- All transmissions utilizing the
@claude-apiprefix consume your purchased Anthropic service credits and will result in expenditure. - Revert to the standard desktop interface for routine queries to conserve credits.
- The API invocation command should be reserved strictly for scenarios demanding:
- Contextual memory exceeding default limits.
- Imposition of specific operational mandates (system prompts).
- Circumvention of API request throttling.
Exposed MCP Toolset
query_claude- Executes raw API requests against the Claude endpoint.
- Supports injection of system-level instructions.
-
Includes built-in mechanism for dialogue state tracking.
-
clear_conversation - Provides a means to instantly reset the historical record for a specific session ID.
-
Facilitates management of concurrent, isolated discussion threads.
-
get_conversation_history - Retrieves the recorded exchange sequence for debugging or review.
- Aids in auditing the flow of interaction.
Engineering Notes
The primary operational server logic resides in src/claude_api_server.py. To extend capabilities, integrate new functions using the @mcp.tool() decorator.
Illustrative example of integrating a novel utility function:
python @mcp.tool() async def calculate_checksum(data_string: str) -> str: """ Computes a cryptographic hash for the input data.
Args:
data_string: The raw text payload to process.
"""
try:
# Implementation logic here
return computed_hash
except Exception as e:
return f"Processing Failure: {str(e)}"
Troubleshooting Guide
- Authentication Failures
- Confirm the API key integrity within the
.envfile. - Validate the configuration file paths in the Claude Desktop support directory.
-
Verify the associated API credentials possess adequate service permissions.
-
Connectivity Issues
- Ensure the dedicated MCP proxy server process is active and listening.
- Check the execution environment and installed Python package health.
-
Examine the local application logs generated by Claude Desktop.
-
Invocation Errors
- Scrutinize the syntax used with the
@claude-apiprefix. - Verify that provided conversation identifiers are correctly formatted.
- Double-check the structure expected for system prompt payloads.
Collaboration
- Create a fork of the current repository.
- Establish a dedicated feature branch for your proposed changes.
- Implement and test your modifications.
- Submit a formal Pull Request for review.
Licensing
This project is governed under the MIT License.
Support Channels
For reported defects or inquiries: 1. File a new issue report within the repository interface. 2. Explore the existing threads and discussions. 3. Consult the detailed troubleshooting documentation above.
