mcp-gateway-service
A robust middleware layer facilitating application integration and expansion via the Microservice Communication Protocol (MCP). It enables automatic discovery and registration of remote API functionalities, featuring deep TypeScript integration for compile-time safety in distributed system construction.
Author

qingtianyu
Quick Info
Actions
Tags
MCP Endpoint Orchestrator
企业级微服务API服务端,支持MCP协议扩展。
✨ Core Capabilities
- Full compliance with the MCP specification (supporting tool extension and resource access).
- Dynamic provisioning and registration of callable API agents.
- Superior type validation via comprehensive TypeScript schema enforcement.
🚀 Getting Started
Prerequisites
- Node.js environment version 18 or newer.
- npm package manager version 9 or above.
- TypeScript compiler version 5.0 or later.
Installation Guide
bash
Obtain the source code repository
git clone https://github.com/your-repo/mcp-api-server.git
Resolve project dependencies
npm install
Execute the production build sequence
npm run build
Configuration Parameters (MCP Context)
{ "mcpServers": { "api-gateway": { "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 Details
Within the mcpServers block, utilize the ALLOWED_APIS list to precisely dictate which HTTP endpoint paths are exposed via the MCP tooling interface:
📂 Repository Structure Overview
bash mcp-api-server/ ├── build/ # Compiled JavaScript output ├── src/ # Source code directory │ ├── config/ # Initialization and environment settings │ ├── modules/ # Core business logic components │ └── tools/ # MCP protocol implementation logic ├── package.json └── tsconfig.json
📡 MCP Tool Manifestation
Automated API Discovery System
The MCP-Server incorporates a mechanism for dynamic discovery and registration of operational endpoints, leveraging the OpenAPI (Swagger) specification to automatically generate valid MCP tooling definitions.
apiEndpoints.ts Logic Description
typescript // Retrieve API contract details from the OpenAPI specification source const openApiData = await fetchOpenApiData();
// Prune the endpoint list based on the configured whitelist const API_ENDPOINTS = Object.entries(openApiData.paths) .filter(([path]) => config.ALLOWED_APIS.includes(path)) .map(([path, methods]) => { // Format data structure into the standard tool descriptor 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 Execution Flow
typescript export function registerTools(server: Server) { // Register the handler for listing available tool signatures server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools, }));
// Handle the invocation request for a specific tool server.setRequestHandler(CallToolRequestSchema, async (request) => { const endpoint = apiMap[request.params.name];
// Select appropriate HTTP client method based on endpoint 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 Discovery: Derives callable agents directly from OpenAPI documents.
- Performance Layer: Implements caching for specification retrieval to mitigate latency and handle transient network failures.
- Schema Mapping: Seamlessly translates OpenAPI input definitions into the required MCP tool schema format.
- Security Boundary: Ensures only explicitly permitted parameters are exposed during tool execution.
- Resilience: Comprehensive error handling ensures stable operation during tool invocation failures.
- Registration Automation: Automatically populates the tool catalog without manual intervention.
🤝 Collaboration Guidelines
- Create a personal fork of the repository.
- Establish a dedicated branch for your changes (
git checkout -b enhancement/my-new-feature). - Commit your modifications (
git commit -m 'Feature: Implement XYZ improvement'). - Push the branch to your remote fork (
git push origin enhancement/my-new-feature). - Submit a formal Pull Request against the main branch.
📄 Licensing
This project is distributed under the MIT License.
WIKIPEDIA: Business management tools are all the systems, applications, controls, calculating solutions, methodologies, etc. used by organizations to be able to cope with changing markets, ensure a competitive position in them and improve business performance.
== Overview == There are tools related to each organization's department which can be classified for each aspect of management. For example: planning tools, process tools, records tools, employee related tools, decision making tools, control tools, etc. A classification by function would consider these general aspects:
Tools used for data input and validation in any department. Tools used for controlling and improving business processes. Tools used for data consolidation and decision making. Nowadays, management tools have evolved dramatically in the last decade thanks to fast technology advances, so fast that it is difficult to select the best business tools for any situation in any company. This is caused by a never-ending fight for lower costs and increase sales, the willingness for understanding the customers' needs, and the fight for delivering the products that meet their need in the way they require. Under this scenario, managers should take a strategic attitude to business management tools instead of going for the latest tool. Usually, managers rely on the tools without any adaptation which leads to an unstable situation. Business management tools should be selected carefully, and then adapted to the organization needs and not the other way around.
== Most used == In 2013, a survey conducted by Bain & Company showed how business tools are used around the globe. These tools reflect how their outcomes contribute to each region's needs, considering the downfall and companies' market situation. The top ten includes:
Strategic planning Customer relationship management Employee engagement surveys Benchmarking Balanced scorecard Core competency Outsourcing Change management programs Supply chain management Mission statement and vision statement Market segmentation Total quality management
== Software application for businesses == Software or collection of computer programs used by business users to carry out various business operations is referred to as business software (or a business application). These business applications are used to boost output, gauge output, and carry out various other company tasks precisely. It started with management information systems and extended into enterprise resource planning systems. Then customer relationship management was added to the solution and finally the whole package moved into the cloud business management space. Although there is an actual correlation between IT efforts and the organizations' performance, two elements are key to add value to the sum; these are the implementation's effectiveness and the proper tools selections and adaptation process.
== Tools for SMEs == The tools focused on SMEs are important because they provide ways to save m
