Skip to content

Commit 0ebcf37

Browse files
authored
MCP server fix (#303)
1 parent 185173c commit 0ebcf37

File tree

10 files changed

+56
-1738
lines changed

10 files changed

+56
-1738
lines changed

deploy/docker/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ CHATBOT_SERVER_PORT=5002
55
ENABLE_SHELL_INJECTION=false
66
ENABLE_LOG4J=false
77
LISTEN_IP="127.0.0.1"
8-
TLS_ENABLED=true
8+
TLS_ENABLED=false
99
VERSION=latest
1010
LOG_LEVEL=INFO

deploy/docker/docker-compose.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ services:
1515
crapi-identity:
1616
container_name: crapi-identity
1717
image: crapi/crapi-identity:${VERSION:-latest}
18-
#ports:
19-
# - "${LISTEN_IP:-127.0.0.1}:8080:8080"
18+
ports:
19+
- "${LISTEN_IP:-127.0.0.1}:8080:8080"
2020
volumes:
2121
- ./keys:/app/keys
2222
environment:
@@ -170,6 +170,8 @@ services:
170170
depends_on:
171171
mongodb:
172172
condition: service_healthy
173+
crapi-identity:
174+
condition: service_healthy
173175
# ports:
174176
# - "${LISTEN_IP:-127.0.0.1}:5002:5002"
175177

services/chatbot/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ RUN pip install --no-cache-dir -r requirements.txt
1616
COPY src /app
1717
COPY certs /app/certs
1818
COPY retrieval /app/retrieval
19+
RUN mkdir -p /app/resources
20+
COPY src/resources/crapi-openapi-spec.json /app/resources/crapi-openapi-spec.json
1921
ENV PYTHONPATH="/app"
2022
COPY entrypoint.sh /app/entrypoint.sh
2123
CMD /app/entrypoint.sh

services/chatbot/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ langchain-openai==0.3.16
66
langchain-text-splitters==0.3.8
77
markdown==3.8
88
pymongo==4.12.1
9-
python-dotenv==1.0.1
9+
python-dotenv==1.1.0
1010
unstructured==0.17.2
1111
numpy==1.26.4
1212
langchain-mcp-adapters==0.1.8
@@ -15,7 +15,7 @@ quart-cors==0.8.0
1515
motor==3.7.1
1616
openai==1.77.0
1717
langgraph==0.5.1
18-
python-dotenv==1.0.1
1918
faiss-cpu==1.11.0
2019
psycopg2-binary
21-
uvicorn==0.35.0
20+
uvicorn==0.35.0
21+
fastmcp==2.10.2

services/chatbot/src/chatbot/langgraph_agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def get_retriever_tool(api_key):
4848
return retriever_tool
4949

5050

51-
async def build_langgraph_agent(api_key, session_id):
51+
async def build_langgraph_agent(api_key):
5252
system_prompt = textwrap.dedent(
5353
"""
5454
You are crAPI Assistant — an expert agent that helps users explore and test the Completely Ridiculous API (crAPI), a vulnerable-by-design application for learning and evaluating modern API security issues.
@@ -93,12 +93,12 @@ async def build_langgraph_agent(api_key, session_id):
9393
tools = mcp_tools + db_tools
9494
# retriever_tool = await get_retriever_tool(api_key)
9595
# tools.append(retriever_tool)
96-
agent_node = create_react_agent(llm, tools=tools, prompt=system_prompt)
96+
agent_node = create_react_agent(model=llm, tools=tools, prompt=system_prompt)
9797
return agent_node
9898

9999

100100
async def execute_langgraph_agent(api_key, messages, session_id=None):
101-
agent = await build_langgraph_agent(api_key, session_id)
101+
agent = await build_langgraph_agent(api_key)
102102
print("messages", messages)
103103
print("Session ID", session_id)
104104
response = await agent.ainvoke({"messages": messages})
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import os
33

4-
from .mcp_server import app
4+
from .server import mcp as app
55

66
# Configure logging
77
logging.basicConfig(
@@ -11,11 +11,5 @@
1111

1212
if __name__ == "__main__":
1313
logger.info("Starting MCP server...")
14-
app.settings.host = "0.0.0.0"
15-
app.settings.port = 5002
16-
app.settings.debug = os.getenv("DEBUG", "False").lower() in (
17-
"true",
18-
"1",
19-
"yes",
20-
)
21-
app.run(transport="streamable-http")
14+
mcp_server_port = int(os.environ.get("MCP_SERVER_PORT", 5500))
15+
app.run(transport="streamable-http", host="0.0.0.0", port=mcp_server_port)

0 commit comments

Comments
 (0)