The MCP API Service is a middleware server that follows the Model Context Protocol (MCP), enabling Claude AI to communicate with internal system APIs. It acts as an intermediary, receiving commands from Claude, processing them, and returning formatted results after interacting with your internal APIs.
To set up the MCP API Service, follow these steps:
npm install
npm run build
npm run watch
The MCP API Service currently supports the following scenarios:
check_connection - Verifies connectivity to the API serversearch_employee - Searches for employees by name or IDregister_breakfast - Registers employees for breakfastupdate_hoa_chat - Updates chemical information by shiftchuyen_nhan_vien_thi_cong - Transfers construction contractorsDebugging MCP can be challenging due to the nature of stdin/stdout communication. To make this easier, you can use the MCP Inspector:
npm run inspector
The inspector provides a web interface that allows you to:
Define new endpoints in src/config.ts:
export const CONFIG = {
// ...existing code...
TOOLS: {
// ...existing code...
NEW_API_GROUP: {
ACTION_API: '/api/services/app/NewService/NewAction'
}
}
}
Define interfaces in src/types.ts for the input/output data:
export interface NewActionInput {
Param1: string;
Param2: number;
// Other parameters...
}
Create a new file in src/services/ or add to an existing service:
// src/services/new-service.service.ts
import { NewActionInput } from '../types.js';
import { ApiClient } from '../utils/api-client.js';
import { Logger } from '../utils/logger.js';
import { CONFIG } from '../config.js';
export class NewService {
private logger = new Logger();
async newAction(input: NewActionInput) {
try {
this.logger.debug('Calling new action API', {
url: CONFIG.TOOLS.NEW_API_GROUP.ACTION_API,
input
});
const response = await ApiClient.post(
CONFIG.TOOLS.NEW_API_GROUP.ACTION_API,
null,
{ params: input }
);
this.logger.info('Action completed successfully', { input });
return response.result;
} catch (error) {
this.logger.error('Error performing action', { error, input });
throw error;
}
}
}
In src/index.ts:
When working with the MCP API Service, follow these guidelines:
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "api-service" '{"command":"npm","args":["run","start"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:
{
"mcpServers": {
"api-service": {
"command": "npm",
"args": [
"run",
"start"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json2. Add this to your configuration file:
{
"mcpServers": {
"api-service": {
"command": "npm",
"args": [
"run",
"start"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect