microservice-communication-platform-engine
Facilitates the extension and integration of applications utilizing dynamic tooling provided via the MCP architectural blueprint, which mandates automated service discovery and interface registration. Provides robust compile-time type verification via TypeScript for safer construction of distributed services.
Author

qingtianyu
Quick Info
Actions
Tags
MCP API Orchestrator Service
Enterprise-grade backend for orchestrating microservices utilizing the Machine Communication Protocol (MCP) specification for tooling.
✨ Core Capabilities
- MCP Protocol Implementation (Supports tool augmentation and resource invocation)
- Runtime Tool Registration (Dynamic binding)
- Comprehensive Static Typing Assurance via TypeScript
🚀 Getting Started
Prerequisites
- Node.js runtime version 18 or higher
- npm package manager version 9 or greater
- TypeScript compiler version 5.0 or newer
Setup Procedure
bash
Clone the repository source code
git clone https://github.com/your-repo/mcp-api-server.git
Install necessary package dependencies
npm install
Compile for production deployment
npm run build
Service Configuration Parameters
{ "mcpServers": { "api-server": { "command": "node", "args": [ "D:/api-server/build/index.js" ], "env": { "BASE_URL": "https://127.0.0.0:8080", "CLIENT_ID": "xxx", "CLIENT_SECRET": "xxx", "USERNAME": "xxx", "PASSWORD": "xxx", "TENANT_ID": "1", "REJECT_UNAUTHORIZED": "false", "ALLOWED_APIS": "/admin-api/system/user/page,/admin-api/system/user/create,/admin-api/system/user/update" }, "disabled": false, "autoApprove": [] } } }
Configuration Notes
Use the ALLOWED_APIS list within the mcpServers object to strictly govern which HTTP interface endpoints are exposed as callable MCP agents:
📂 Directory Layout
bash mcp-api-server/ ├── build/ # Compiled output assets ├── src/ # Primary source files │ ├── config/ # Configuration management utilities │ ├── modules/ # Business logic components │ └── tools/ # MCP protocol definitions and handlers ├── package.json └── tsconfig.json
📡 Dynamic Tool Provisioning
Automated Interface Agent System
The MCP-Server implements a mechanism for deriving and registering operational interfaces dynamically based on the OpenAPI (OAS) specification schema, obviating the necessity for manual interface definition.
apiEndpoints.ts Logic Flow
typescript // Retrieve interface metadata from the OpenAPI specification source const openApiData = await fetchOpenApiData();
// Filter endpoints based on the predefined whitelist const API_ENDPOINTS = Object.entries(openApiData.paths) .filter(([path]) => config.ALLOWED_APIS.includes(path)) .map(([path, methods]) => { // Map to the standardized tool format return Object.entries(methods).map(([method, details]) => ({ name: details.operationId, description: details.summary, inputSchema: details.parameters ? { type: 'object', properties: Object.fromEntries(details.parameters .filter(isExposableParameter) .map(transformParameterToProperty) ) } : {}, path: path, method: method.toUpperCase() })); }).flat();
tools/index.ts Agent Registration Mechanism
typescript export function registerTools(server: Server) { // Register the manifest of available agents server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools, }));
// Process incoming agent invocation requests server.setRequestHandler(CallToolRequestSchema, async (request) => { const endpoint = apiMap[request.params.name];
// Execute dynamic request dispatch based on HTTP verb
if(endpoint.method === 'GET') {
const response = await apiClient.get(endpoint.path, { params: request.params.arguments });
return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }] };
} else if(endpoint.method === 'POST') {
const response = await apiClient.post(endpoint.path, request.params.arguments);
return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }] };
} else if(endpoint.method === 'PUT') {
const response = await apiClient.put(endpoint.path, request.params.arguments);
return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }] };
}
}); }
Key System Advantages
- Automatic Interface Harvesting: Derives and binds API interfaces straight from the OAS definition
- Data Persistence Layer: Incorporates specification data caching to boost throughput and mitigate network instability issues
- Input Schema Projection: Seamlessly translates OAS parameter definitions into the required MCP agent input structure
- Security Filtering: Systematically scrubs internal parameters, exposing only sanctioned interface arguments
- Robust Failure Handling: Comprehensive error management protocols ensure operational resilience during tool calls
- Manifest Generation: Automatically generates the list of accessible tools, bypassing manual registration overhead
🤝 Contribution Guidelines
- Fork the current repository instance
- Establish a dedicated feature branch (
git checkout -b refinement/new-capability) - Commit changes (
git commit -m 'Implement feature X') - Push the branch to origin (
git push origin refinement/new-capability) - Submit a formal Pull Request
📄 Licensing Information
Under the terms of the MIT License
WIKIPEDIA: XMLHttpRequest (XHR) is an Application Programming Interface implemented as a JavaScript object designed to shuttle Hypertext Transfer Protocol requests between a web browser and a server. Its methods permit an application executing within the browser to transmit queries to the remote host following page load completion, and subsequently receive data back. XMLHttpRequest forms a foundational pillar of the Ajax programming paradigm. Before Ajax's advent, navigation links and form submissions constituted the dominant methods for server interaction, frequently resulting in a full page refresh.
== Chronology == The foundational concept underpinning XMLHttpRequest was conceptualized in the year 2000 by software engineers working on Microsoft Outlook. This concept was subsequently realized within the Internet Explorer 5 browser release (1999). Nevertheless, the original invocation syntax did not employ the 'XMLHttpRequest' nominal identifier. Instead, developers utilized the 'ActiveXObject("Msxml2.XMLHTTP")' and 'ActiveXObject("Microsoft.XMLHTTP")' instantiators. As of Internet Explorer version 7 (released in 2006), support for the standard 'XMLHttpRequest' identifier became universal across all major browser platforms. The 'XMLHttpRequest' identifier has since solidified its position as the established convention across all principal browsers, including Mozilla's Gecko rendering engine (since 2002), Safari version 1.2 (2004), and Opera version 8.0 (2005).
=== Formal Specifications === The World Wide Web Consortium (W3C) promulgated a preliminary Working Draft specification for the XMLHttpRequest object on April 5th, 2006. On February 25th, 2008, the W3C advanced this to a Level 2 Working Draft specification. Level 2 introduced novel methods allowing for event progress monitoring, enabling cross-origin resource sharing (CORS), and facilitating the handling of raw byte streams. By the close of 2011, the Level 2 specifications were merged back into the primary document. At the termination of 2012, development responsibility was transitioned to the WHATWG, which now maintains a continuously evolving document leveraging Web IDL notation.
== Operational Usage Pattern == Generally, executing a network request utilizing XMLHttpRequest necessitates adherence to several sequential programming stages.
Instantiate an XMLHttpRequest object via its constructor function: Invoke the 'open' method to designate the request methodology, specify the targeted resource URI, and select between synchronous or asynchronous execution mode: For asynchronous operations, define a listener callback function intended to trigger upon alterations in the request's internal state: Commence the transmission of the request by calling the 'send' method: Process state transitions within the registered event handler. If the server successfully delivers response payload data, this content is, by default, stored within the 'responseText' attribute. Upon completion of response processing, the object transitions to state 4, denoting the 'done' status. Beyond these fundamental steps, XMLHttpRequest furnishes numerous optional controls to govern request transmission parameters and subsequent response interpretation. Custom request header fields can be appended to direct server fulfillment logic, and payload data can be submitted to the server by supplying it as an argument to the 'send' invocation. The returned data stream can be deserialized from JSON format into a readily usable JavaScript object structure, or processed incrementally as data arrives, foregoing the wait for the entirety of the content. The operation can be halted prematurely or configured to timeout if completion is not achieved within a specified temporal window.
== Inter-Domain Communication ==
During the nascent stages of the World Wide Web's evolution, mechanisms were discovered that allowed for the breaching of the same-origin policy, leading to security vulnerabilities...
