A Model Context Protocol (MCP) server that interacts with system APIs, allowing users to check connections, search employees, register breakfast, and update chemical information by shifts.
Máy chủ Model Context Protocol (MCP) để tương tác với các API hệ thống nội bộ
MCP API Service là một máy chủ trung gian hoạt động theo giao thức Model Context Protocol (MCP), giúp kết nối Claude AI với các API hệ thống nội bộ. Hệ thống này:
Máy chủ MCP hoạt động bằng cách giao tiếp qua stdio (standard input/output):
Quy trình khi một yêu cầu được gửi:
Các kịch bản hiện có:
check_connection
- Kiểm tra kết nối tới API serversearch_employee
- Tìm kiếm nhân viên theo tên hoặc mãregister_breakfast
- Đăng ký ăn sáng cho nhân viênupdate_hoa_chat
- Cập nhật thông tin hóa chất theo cachuyen_nhan_vien_thi_cong
- Chuyển nhân viên thi công giao khoánĐịnh nghĩa endpoint mới trong src/config.ts
:
export const CONFIG = { // ...existing code... TOOLS: { // ...existing code... TEN_NHOM_API: { ACTION_API: '/api/services/app/TenService/TenAction' } } }
Tạo interface trong src/types.ts
cho dữ liệu đầu vào/đầu ra:
export interface TenActionInput { Param1: string; Param2: number; // Các tham số khác... }
Tạo file mới trong src/services/
hoặc thêm vào service hiện có:
// src/services/ten-service.service.ts import { TenActionInput } from '../types.js'; import { ApiClient } from '../utils/api-client.js'; import { Logger } from '../utils/logger.js'; import { CONFIG } from '../config.js'; export class TenService { private logger = new Logger(); async tenAction(input: TenActionInput) { try { this.logger.debug('Calling ten action API', { url: CONFIG.TOOLS.TEN_NHOM_API.ACTION_API, input }); const response = await ApiClient.post( CONFIG.TOOLS.TEN_NHOM_API.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; } } }
Trong src/index.ts
:
Cài đặt thư viện:
npm install
Build server:
npm run build
Chạy chế độ phát triển với tự động build lại:
npm run watch
Việc gỡ lỗi MCP gặp khó khăn vì:
Sử dụng MCP Inspector để:
Khởi động Inspector:
npm run inspector
Inspector sẽ cung cấp URL truy cập giao diện web để theo dõi hoạt động của hệ thống.
Nhất Quán
Xử Lý Lỗi
Logging
Validation
Xem thêm chi tiết trong docs/add-new-scenario.md
.
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!