Repository navigation
MCP Server
Model Context Protocol (MCP) is a standard that lets AI models call external tools in a structured way. Instead of the AI guessing at a solution, MCP lets it take real actions — read files, run commands, search code — and receive real results back before deciding the next step.
The MCP Server uses SSE (Server-Sent Events) as its transport layer.
-
GET /sse— The Backend connects here when it starts up. This establishes a persistent session. -
POST /messages?sessionId=...— Tool calls from the AI are sent here during the agent loop.
When the backend boots, it immediately connects to the MCP Server via /sse and holds that connection open. Every tool call during an agent loop goes through this session.
Lists all files and folders inside a given directory. The AI uses this first to understand the structure of the uploaded project.
Input: directorypath — path to the project directory.
Reads the full content of a single file. The AI uses this after identifying which files are relevant.
Input: filepath — absolute path to the file.
Searches for a keyword or phrase across all files in the project. Useful for tracing where a variable, function, or error message is used.
Input: directoryPath — project root. keyword — the string to search for.
Executes a terminal command inside the project directory. The AI uses this to install dependencies, start the project, or reproduce the error.
Input: command — the command string. workingDirectory — where to run it.
Takes raw runtime logs or error output and returns an analysis of what went wrong and why.
Input: logs — the error or log string.
Writes or overwrites a file with new content. The AI uses this to apply fixes after identifying the root cause.
Input: filepath — file to write. content — new file content.
The agent follows this general sequence, though it adapts based on what it finds:
- Call
listFilesto understand the project structure. - Call
searchCodebaseto find relevant code related to the bug. - Call
readFileon files that look important. - Call
runCommandto reproduce the error or check runtime behavior. - Call
analyzeLogson the output. - Call
writeFileto apply a fix if needed. - Return a final explanation to the user.
The loop runs for a maximum of 20 tool calls. If the limit is reached, the agent returns whatever conclusion it has reached so far.
Each tool call has a timeout (10–15 seconds depending on the tool). If a tool does not respond in time, the agent receives a timeout message and continues to the next step. This prevents the loop from hanging on slow commands like npm install.