Overview
Overview
MCP is a message protocol (often JSON-RPC) carried over a transport. stdio has no port; HTTP/HTTPS uses a URL endpoint (typically port 443 in production). Use the tabs above to jump to each section.
MCP does not “live” on a fixed port. It is used as a message protocol (often JSON-RPC) carried over a transport. That’s why stdio has no port, and HTTP/HTTPS uses a server URL endpoint (the port is simply your web service port: typically 443 in production, or something else in development).
MCP is a message protocol (often JSON-RPC) carried over a transport. stdio has no port; HTTP/HTTPS uses a URL endpoint (typically port 443 in production). Use the tabs above to jump to each section.
In production, the most common setup is to put your MCP server behind a reverse proxy / API gateway and expose an endpoint like: https://api.yourcompany.com/mcp/v1
Practical note: “pointing to the endpoint” also implies you must handle authentication, CORS (if a browser is involved), rate limits, and logging/observability.
Think of an MCP server like a well-run building, where each role has a clear responsibility.
Below that is the “operations floor”: method routing, the tool catalog, resource access, and prompt templates. This separation helps you scale, audit, and control risk with less friction.
This is a strong “enterprise-ready” breakdown because it separates: config → transport → guardrails → orchestration → capabilities.
| Layer / Component | Pattern | Responsibility | Practical notes |
|---|---|---|---|
MCPConfig |
Singleton | Central configuration; tool/resource definitions; security settings; database credentials | This is where you define the “surface area” (what exists) and the connectivity (DB/API endpoints). |
MCPTransportFactory |
Factory | Detects CLI vs HTTP; creates appropriate transport; returns MCPTransportInterface |
Lets the same server run locally (stdio) or remotely (HTTP) with minimal changes. |
MCPTransportHandler |
Validation / Gateway | JSON-RPC validation; rate limiting; authentication; logging | Your “security gate”: validate inputs, protect endpoints, and provide auditability. |
MCPServer |
Orchestrator | Event loop; method routing; error handling; initialization tracking | Control center: receives requests, routes to tools/resources/prompts, and normalizes errors. |
MCPTools |
Tool Catalog | Hardcoded tool list; switch-based routing; delegates to agent_tools.php; MCP format wrapping | Recommendation: evolve from a hardcoded switch to a declarative registry as the catalog grows. |
MCPResources |
Data Access | Hardcoded URI list; direct SQL queries; read-only access; filtering & pagination | Ideal for a safe “context surface”: curated resources, pagination, strict limits, and access control. |
MCPPrompts |
Templates | Loads in constructor; template substitution; argument validation; in-memory storage | Great for standardizing tasks (triage, QA, PRDs). Add versioning and template tests over time. |
This is a strong “enterprise-ready” breakdown because it separates: config → transport → guardrails → orchestration → capabilities.
| Layer / Component | Pattern | Responsibility | Practical notes |
|---|---|---|---|
MCPConfig |
Singleton | Central configuration; tool/resource definitions; security settings; database credentials | This is where you define the “surface area” (what exists) and the connectivity (DB/API endpoints). |
MCPTransportFactory |
Factory | Detects CLI vs HTTP; creates appropriate transport; returns MCPTransportInterface |
Lets the same server run locally (stdio) or remotely (HTTP) with minimal changes. |
MCPTransportHandler |
Validation / Gateway | JSON-RPC validation; rate limiting; authentication; logging | Your “security gate”: validate inputs, protect endpoints, and provide auditability. |
MCPServer |
Orchestrator | Event loop; method routing; error handling; initialization tracking | Control center: receives requests, routes to tools/resources/prompts, and normalizes errors. |
MCPTools |
Tool Catalog | Hardcoded tool list; switch-based routing; delegates to agent_tools.php; MCP format wrapping | Recommendation: evolve from a hardcoded switch to a declarative registry as the catalog grows. |
MCPResources |
Data Access | Hardcoded URI list; direct SQL queries; read-only access; filtering & pagination | Ideal for a safe “context surface”: curated resources, pagination, strict limits, and access control. |
MCPPrompts |
Templates | Loads in constructor; template substitution; argument validation; in-memory storage | Great for standardizing tasks (triage, QA, PRDs). Add versioning and template tests over time. |
Optional: send a comment about this article.