Skip to content

Commit 4cbf3bb

Browse files
committed
fix: update MCP server configuration to use SSE transport and environment variables
1 parent c0bf768 commit 4cbf3bb

File tree

3 files changed

+58
-62
lines changed

3 files changed

+58
-62
lines changed

docker-compose.yml

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,26 @@ services:
1717
- qdrant
1818

1919
mcp-server:
20-
build: .
21-
ports:
22-
- "3001:3001" # Add port mapping for the MCP server
20+
build:
21+
context: .
22+
dockerfile: Dockerfile
2323
environment:
24+
- MCP_TRANSPORT=sse
25+
- MCP_HOST=0.0.0.0
26+
- MCP_PORT=3001
2427
- LLM_API_KEY=${LLM_API_KEY}
25-
- LLM_API_BASE=${LLM_API_BASE:-https://coder.gaia.domains/v1}
26-
- LLM_MODEL=${LLM_MODEL:-Qwen2.5-Coder-32B-Instruct-Q5_K_M}
27-
- LLM_EMBED_MODEL=${LLM_EMBED_MODEL:-nomic-embed}
28-
- LLM_EMBED_SIZE=${LLM_EMBED_SIZE:-768}
2928
- QDRANT_HOST=qdrant
3029
- QDRANT_PORT=6333
30+
command: python -m examples.run_mcp_server
31+
volumes:
32+
- .:/app
3133
depends_on:
3234
- qdrant
33-
# Use the run_mcp_server.py script which properly sets up the server
34-
command: python -m examples.run_mcp_server
35-
35+
3636
mcp-proxy:
37-
image: sparfenyuk/mcp-proxy:latest
37+
image: ghcr.io/microsoft/mcp-proxy:latest
3838
ports:
3939
- "3000:3000"
40-
volumes:
41-
- ./mcp-proxy-config.json:/app/mcp-proxy-config.json
40+
command: http://mcp-server:3001/sse --port 3000 --host 0.0.0.0 --allow-origin="*"
4241
depends_on:
43-
- mcp-server
44-
45-
qdrant:
46-
image: qdrant/qdrant
47-
ports:
48-
- "6333:6333"
49-
volumes:
50-
- ./qdrant_data:/qdrant/storage
42+
- mcp-server

examples/run_mcp_server.py

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,52 @@
1+
import os
12
from app.mcp_server import RustMCPServer
2-
from app.mcp_service import RustCompilerMCP
3-
from app.llm_client import LlamaEdgeClient
43
from app.vector_store import QdrantStore
5-
from app.compiler import RustCompiler
6-
from app.response_parser import ResponseParser
7-
import os
4+
from app.llm_client import LlamaEdgeClient
5+
from app.mcp_service import RustCompilerMCP
86
from dotenv import load_dotenv
97

10-
load_dotenv()
11-
128
def main():
13-
# Initialize components
14-
api_key = os.getenv("LLM_API_KEY")
15-
llm_embed_size = int(os.getenv("LLM_EMBED_SIZE", "1536"))
9+
load_dotenv()
1610

17-
# Get LLM API base URL
18-
llm_api_base = os.getenv("LLM_API_BASE", "https://coder.gaia.domains/v1")
19-
llm_model = os.getenv("LLM_MODEL", "Qwen2.5-Coder-32B-Instruct-Q5_K_M")
20-
llm_embed_model = os.getenv("LLM_EMBED_MODEL", "nomic-embed")
21-
22-
# Get Qdrant connection details
23-
qdrant_host = os.getenv("QDRANT_HOST", "localhost")
24-
qdrant_port = int(os.getenv("QDRANT_PORT", "6333"))
25-
26-
# Set environment variables for QdrantStore
27-
os.environ["QDRANT_HOST"] = qdrant_host
28-
os.environ["QDRANT_PORT"] = str(qdrant_port)
11+
# Get API key from environment variable
12+
api_key = os.getenv("LLM_API_KEY")
13+
if not api_key:
14+
raise ValueError("LLM_API_KEY environment variable not set")
2915

30-
# Initialize LlamaEdgeClient with all required parameters
31-
llm_client = LlamaEdgeClient(api_key=api_key, api_base=llm_api_base, model=llm_model, embed_model=llm_embed_model)
16+
# Get embedding size from environment variable
17+
llm_embed_size = int(os.getenv("LLM_EMBED_SIZE", "1536"))
3218

33-
# Initialize QdrantStore with just the embedding_size parameter
19+
# Initialize components
20+
llm_client = LlamaEdgeClient(api_key=api_key)
3421
vector_store = QdrantStore(embedding_size=llm_embed_size)
35-
vector_store.create_collection("project_examples")
36-
vector_store.create_collection("error_examples")
37-
38-
# Initialize MCP service
22+
23+
# Create collections
24+
try:
25+
vector_store.create_collection("project_examples")
26+
print("Created collection: project_examples")
27+
except Exception as e:
28+
if "already exists" in str(e):
29+
print("Collection project_examples already exists")
30+
else:
31+
raise
32+
33+
try:
34+
vector_store.create_collection("error_examples")
35+
print("Created collection: error_examples")
36+
except Exception as e:
37+
if "already exists" in str(e):
38+
print("Collection error_examples already exists")
39+
else:
40+
raise
41+
42+
# Initialize service and server
3943
mcp_service = RustCompilerMCP(vector_store=vector_store, llm_client=llm_client)
40-
41-
# Create and run MCP server
4244
server = RustMCPServer(mcp_service)
4345

44-
print("Starting MCP server on 0.0.0.0:3001")
45-
server.run(host="0.0.0.0", port=3001)
46+
# Start the server
47+
host = os.getenv("MCP_HOST", "0.0.0.0")
48+
port = int(os.getenv("MCP_PORT", "3001"))
49+
server.run(host=host, port=port)
4650

4751
if __name__ == "__main__":
4852
main()

mcp-proxy-config.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"providers": [
3-
{
4-
"name": "rust-compiler",
5-
"url": "http://mcp-server:3001/sse",
6-
"methods": ["compile", "compileAndFix", "vectorSearch"]
7-
}
8-
]
9-
}
2+
"providers": [
3+
{
4+
"name": "rust-compiler",
5+
"url": "http://mcp-server:3001/sse",
6+
"methods": ["compile", "compileAndFix", "vectorSearch"]
7+
}
8+
]
9+
}

0 commit comments

Comments
 (0)