api-mockingbird
Version:
MCP server for creating HTTP mock APIs for frontend development
48 lines (47 loc) • 1.76 kB
JavaScript
import { ADD_ENDPOINT_TOOL, handleAddEndpoint } from './addEndpoint.js';
import { LIST_ENDPOINTS_TOOL, handleListEndpoints } from './listEndpoints.js';
import { REMOVE_ENDPOINT_TOOL, handleRemoveEndpoint, } from './removeEndpoint.js';
import { SET_ENDPOINT_ERROR_TOOL, handleSetEndpointError, } from './setEndpointError.js';
import { START_MOCK_SERVER_TOOL, handleStartMockServer, } from './startMockServer.js';
import { STOP_MOCK_SERVER_TOOL, handleStopMockServer, } from './stopMockServer.js';
import { TOGGLE_ENDPOINT_ERROR_TOOL, handleToggleEndpointError, } from './toggleEndpointError.js';
export const TOOL_REGISTRY = {
[START_MOCK_SERVER_TOOL.name]: {
tool: START_MOCK_SERVER_TOOL,
handler: handleStartMockServer,
},
[STOP_MOCK_SERVER_TOOL.name]: {
tool: STOP_MOCK_SERVER_TOOL,
handler: handleStopMockServer,
},
[ADD_ENDPOINT_TOOL.name]: {
tool: ADD_ENDPOINT_TOOL,
handler: handleAddEndpoint,
},
[REMOVE_ENDPOINT_TOOL.name]: {
tool: REMOVE_ENDPOINT_TOOL,
handler: handleRemoveEndpoint,
},
[LIST_ENDPOINTS_TOOL.name]: {
tool: LIST_ENDPOINTS_TOOL,
handler: handleListEndpoints,
},
[SET_ENDPOINT_ERROR_TOOL.name]: {
tool: SET_ENDPOINT_ERROR_TOOL,
handler: handleSetEndpointError,
},
[TOGGLE_ENDPOINT_ERROR_TOOL.name]: {
tool: TOGGLE_ENDPOINT_ERROR_TOOL,
handler: handleToggleEndpointError,
},
};
export function getAllTools() {
return Object.values(TOOL_REGISTRY).map((entry) => entry.tool);
}
export function getToolHandler(name) {
const entry = TOOL_REGISTRY[name];
return entry?.handler ?? null;
}
export function isValidToolName(name) {
return name in TOOL_REGISTRY;
}