home / mcp / onlinegdb mcp server
Provides an HTTP MCP server to execute C++ code via OnlineGDB, test solutions, optimize code, and generate test cases for problems.
Configuration
View docs{
"mcpServers": {
"ayushtiwari110-gdb-mcp-server": {
"url": "http://localhost:3000/mcp"
}
}
}You can run C++ code, test solutions, and analyze performance through an HTTP-based MCP server that uses OnlineGDB’s online compiler. It lets you execute code, validate answers against multiple test cases, optimize solutions, and generate test data, all through an MCP client without needing local compilers.
Use an MCP client to connect to the OnlineGDB MCP Server over HTTP. You can execute small snippets of C++ code, submit full solutions for problem-specific test cases, analyze performance, and generate test data. Each tool returns results you can inspect, iterate on, and refine until you meet all constraints.
Typical usage patterns include running a basic snippet to verify output, submitting a complete solution with multiple test cases, and then measuring runtime and memory usage to guide optimizations. When errors occur, you review compilation or runtime messages, adjust your code, and re-run tests until you achieve the desired results.
Prerequisites: Node.js and npm installed on your machine.
Step by step setup to run the MCP server locally:
git clone <repository-url>
cd onlinegdb-mcp-server
npm install
npm run build
npm start
```
The server starts on port 3000 by default and exposes:
- HTTP MCP endpoint at POST /mcp
- REST endpoints at GET /tools/list and GET /health
- Web UI at GET /The MCP server provides a dedicated HTTP interface for integration with MCP clients. Use the HTTP endpoint to initialize, call tools, and receive structured responses.
Key endpoints you will interact with:
- POST /mcp — primary MCP transport for tool execution and orchestration.
Common issues and quick fixes include ensuring port 3000 is available, setting a different port via PORT, and installing dependencies with npm install.
If the browser automation layer encounters problems, verify system dependencies for Puppeteer and ensure the environment has network access to OnlineGDB services.
The server exposes a set of tools designed for C++ code execution and evaluation, including explicit capabilities to run code, validate solutions, optimize code, and generate test cases.
You can perform iterative development by creating a basic program, validating it against test cases, analyzing performance, and refining the solution accordingly.
Execute C++ code with optional input, returning the program output and basic metadata such as execution time.
Test a complete C++ solution against multiple test cases, returning per-case results and overall status.
Analyze C++ code to suggest performance improvements within given constraints.
Generate test cases for a described problem to support thorough validation of solutions.