DE

DeepSeek MCP Server for Model Context APIs

Integrate with the DeepSeek MCP server to access advanced language models and versatile API endpoints for model context.

Quick Install
npx -y @DMontgomery40/deepseek-mcp-server

Overview

DeepSeek MCP Server is an open-source implementation of the Model Context Protocol (MCP) that exposes a standardized HTTP/WebSocket API for exchanging context with language models, orchestrating multi-model workflows, and persisting context artifacts. It acts as a middle layer between client applications and one or more model backends, unifying prompts, context fragments, embeddings, and metadata so developers can build reproducible, context-aware AI features.

Designed for teams building retrieval-augmented generation (RAG), multi-turn chat, or hybrid tool chains, DeepSeek makes it easier to manage model sessions, attach auxiliary resources (documents, embeddings, tool outputs), and serve streaming responses to clients. The server provides a compact set of endpoints that align with MCP conventions while remaining adaptable to different model hosts and vector stores.

Features

  • HTTP and WebSocket APIs implementing core MCP endpoints
  • Session and context management for multi-turn interactions
  • Support for adding/searching context resources (documents, embeddings)
  • Pluggable backend model hosts and vector stores
  • Streaming inference responses (SSE/WebSocket)
  • API key or token-based access control via environment variables
  • Docker-friendly deployment with adjustable configuration via env vars

Installation / Configuration

Prerequisites: Docker (recommended) or a host runtime compatible with the repository (see project README for language/toolchain specifics).

Clone the repo:

git clone https://github.com/DMontgomery40/deepseek-mcp-server.git
cd deepseek-mcp-server

Quick start with Docker:

# Build (if Dockerfile is present) or pull if an image exists
docker build -t deepseek-mcp-server .

# Run with environment variables
docker run -p 8080:8080 \
  -e PORT=8080 \
  -e API_KEY=supersecret \
  -e MODEL_BACKEND_URL=https://your-model-host.example.com \
  deepseek-mcp-server

Example docker-compose.yml:

version: '3.8'
services:
  deepseek:
    image: deepseek-mcp-server:latest
    ports:
      - "8080:8080"
    environment:
      - PORT=8080
      - API_KEY=supersecret
      - MODEL_BACKEND_URL=https://your-model-host.example.com
      - VECTOR_DB_URL=http://vector-db:8200
  vector-db:
    image: your/vector-db:latest
    ports:
      - "8200:8200"

Common environment variables:

  • PORT: HTTP port (default 8080)
  • API_KEY: token to restrict access
  • MODEL_BACKEND_URL: URL for the model inference host (can be an aggregator)
  • VECTOR_DB_URL: vector store endpoint for embeddings and search
  • LOG_LEVEL: debug/info/warn/error

Available Resources

The server exposes MCP-aligned endpoints to manage sessions, contexts, models, and streaming responses. Below is a concise reference:

MethodPathPurpose
POST/v1/sessionsCreate a new session/context
GET/v1/sessions/{id}Retrieve session state
POST/v1/sessions/{id}/resourcesAdd documents/embeddings to session
POST/v1/inferSubmit inference request (non-streaming)
GET / WS/v1/stream/{session_id}Stream model responses (SSE or WebSocket)
POST/v1/searchVector search across stored resources
GET/v1/modelsList configured model backends

Example: add a resource to a session

curl -X POST "http://localhost:8080/v1/sessions/abc123/resources" \
  -H "Authorization: Bearer supersecret" \
  -H "Content-Type: application/json" \
  -d '{"type":"document","text":"Q1: How to install?","metadata":{"source":"faq"}}'

Use Cases

  1. Retrieval-Augmented Generation (RAG)

    • Store a corpus of documents as session resources (text + embeddings).
    • On user query, call /v1/search to fetch the most relevant passages and include them in /v1/infer payload to produce grounded answers.
  2. Multi-turn Chat with Persistent Context

    • Create a session per user (/v1/sessions).
    • Append user messages and model outputs to the session resources.
    • Use /v1/stream/{session_id} to deliver incremental responses to client UIs while preserving conversation history.
  3. Multi-model Orchestration

    • Configure multiple model backends via MODEL_BACKEND_URL or a registry.
    • Route generation requests to different models based on profile (e.g., fast/cheap vs. high-quality) through the /v1/infer endpoint.
  4. Tool Integration and Metadata Tracking

    • Record the outputs of external tools (search engines, knowledge graph lookups) as session resources with metadata.
    • Include tool outputs as context before calling a model to ensure deterministic, auditable behavior.

Example inference request (non-streaming):

curl -X POST "http://localhost:8080/v1/infer" \
  -H "Authorization: Bearer supersecret" \
  -H "Content-Type: application/json" \
  -d '{
    "session_id":"abc123",
    "model":"gpt-like-model",
    "messages":[{"role":"user","content":"Summarize the documents for me"}],
    "max_tokens":512
  }'

Getting Help and Contributing

  • Repository: https://github.com/DMontgomery40/deepseek-mcp-server
  • Open issues or pull requests in the GitHub project for feature requests, bug reports, and community contributions.
  • Check the repository README and docs subdirectory (if present) for platform-specific build instructions and extension points (e.g., adding new model adapters or vector store connectors).