一键导入
mocking-and-mcp-testing
Specialized guidelines on testing GLPI REST endpoints alongside the MCP Server protocol.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Specialized guidelines on testing GLPI REST endpoints alongside the MCP Server protocol.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | Mocking and MCP Testing |
| description | Specialized guidelines on testing GLPI REST endpoints alongside the MCP Server protocol. |
The primary objective of testing this server is to ensure the MCP input payloads from natural language prompts are well parsed, structured, and executed without directly pinging a live GLPI REST API (which depends on tokens, passwords and strict network settings).
jest.mock)You should avoid making realistic network HTTP requests from the glpi-client.ts. By abstracting src/services/, you test whether the src/tools/ correctly pass instructions.
import { myServiceFunction } from '../../services/glpi-client';
// Use jest to mock the imported dependency entirely
jest.mock('../../services/glpi-client');
You must manually specify what the mocked function should return as an asynchronous promise. E.g.:
const mockServiceFunction = myServiceFunction as jest.MockedFunction<typeof myServiceFunction>;
mockServiceFunction.mockResolvedValue({ status: 200, data: 'Mocked Ticket Object' });
The Model Context Protocol requires tools to respond with an array of structured text. Always assert that tools return exactly:
{
content: [
{
type: "text",
text: expect.any(String) // Usually JSON serialized or formatted markdown
}
]
}
Validate the catch {} mechanisms returning error strings instead of crashing the MCP Server.
mockServiceFunction.mockRejectedValue(new Error('GLPI API Timeout'));
// your expectations should verify that the MCP tool gracefully outputs the text: "Error: GLPI API Timeout".