|
|
|
""" |
|
DeepSeek MCP Server for Claude CLI Integration |
|
|
|
This script runs the MCP server optimized for Claude CLI usage. |
|
""" |
|
|
|
import os |
|
import sys |
|
import json |
|
import logging |
|
from pathlib import Path |
|
|
|
def setup_claude_environment(): |
|
"""Setup environment variables optimized for Claude CLI""" |
|
|
|
os.environ['MCP_GPU_LAYERS'] = '35' |
|
os.environ['MCP_CONTEXT_SIZE'] = '4096' |
|
os.environ['MCP_DEFAULT_MAX_TOKENS'] = '512' |
|
os.environ['MCP_DEFAULT_TEMPERATURE'] = '0.7' |
|
os.environ['MCP_DEFAULT_TOP_P'] = '0.9' |
|
os.environ['MCP_LOG_LEVEL'] = 'INFO' |
|
os.environ['MCP_USE_MLOCK'] = 'true' |
|
os.environ['MCP_LOW_VRAM'] = 'false' |
|
|
|
def create_claude_config(): |
|
"""Create Claude Desktop configuration""" |
|
config_dir = Path.home() / "AppData" / "Roaming" / "Claude" |
|
config_file = config_dir / "claude_desktop_config.json" |
|
|
|
|
|
config_dir.mkdir(parents=True, exist_ok=True) |
|
|
|
|
|
current_dir = Path(__file__).parent.absolute() |
|
|
|
config = { |
|
"mcpServers": { |
|
"deepseek-mcp-server": { |
|
"command": "python", |
|
"args": [str(current_dir / "server.py")], |
|
"env": { |
|
"MCP_GPU_LAYERS": "35", |
|
"MCP_CONTEXT_SIZE": "4096", |
|
"MCP_DEFAULT_MAX_TOKENS": "512", |
|
"MCP_DEFAULT_TEMPERATURE": "0.7", |
|
"MCP_LOG_LEVEL": "INFO" |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
with open(config_file, 'w') as f: |
|
json.dump(config, f, indent=2) |
|
|
|
print(f"Claude Desktop configuration created at: {config_file}") |
|
return config_file |
|
|
|
def main(): |
|
"""Main function to run MCP server for Claude CLI""" |
|
print("Starting DeepSeek MCP Server for Claude CLI...") |
|
|
|
|
|
setup_claude_environment() |
|
|
|
|
|
config_file = create_claude_config() |
|
|
|
print("\nSetup Instructions:") |
|
print("1. Restart Claude Desktop if it's running") |
|
print("2. The MCP server will be automatically available in Claude") |
|
print("3. You can use the following tools:") |
|
print(" - chat: Interactive conversation with DeepSeek") |
|
print(" - generate: Text generation and completion") |
|
|
|
print(f"\nConfiguration file: {config_file}") |
|
print("\nServer starting...") |
|
|
|
|
|
try: |
|
from mcp_interface import MCPLLMInterface |
|
from config import config |
|
import asyncio |
|
|
|
|
|
config.validate() |
|
print(f"Model file found: {config.model_path}") |
|
|
|
|
|
interface = MCPLLMInterface(config.model_path) |
|
print("MCP Server ready for Claude CLI!") |
|
|
|
asyncio.run(interface.run()) |
|
|
|
except KeyboardInterrupt: |
|
print("\nServer stopped by user") |
|
except Exception as e: |
|
print(f"Error: {e}") |
|
sys.exit(1) |
|
|
|
if __name__ == "__main__": |
|
main() |
|
|