breathe-api
Version:
Model Context Protocol server for Breathe HR APIs with Swagger/OpenAPI support - also works with custom APIs
231 lines • 8.82 kB
JavaScript
import { resourceTools } from './resource-tools.js';
const mcpResourceTools = resourceTools.map(tool => {
const zodSchema = tool.inputSchema;
const shape = zodSchema._def?.shape?.() || {};
const properties = {};
const required = [];
for (const [key, value] of Object.entries(shape)) {
const zodField = value;
properties[key] = {
type: 'string',
description: zodField._def?.description
};
if (zodField._def?.values) {
properties[key].enum = zodField._def.values;
}
if (!zodField.isOptional()) {
required.push(key);
}
}
return {
name: tool.name,
description: tool.description,
inputSchema: {
type: 'object',
properties,
required: required.length > 0 ? required : undefined
}
};
});
export const apiTools = [
...mcpResourceTools,
{
name: 'cache_stats',
description: 'Get cache statistics to monitor performance and cache effectiveness',
inputSchema: {
type: 'object',
properties: {},
},
},
{
name: 'clear_cache',
description: 'Clear specific cache or all caches. Useful when API data has changed.',
inputSchema: {
type: 'object',
properties: {
cacheType: {
type: 'string',
enum: ['swagger', 'api', 'all'],
description: 'Which cache to clear',
default: 'all',
},
},
},
},
{
name: 'rate_limit_status',
description: 'Get current rate limit status for all tools',
inputSchema: {
type: 'object',
properties: {},
},
},
{
name: 'explain_api_feature',
description: 'Explain how Breathe HR features work by analyzing API endpoints and providing implementation guidance. ' +
'AUTOMATICALLY searches BOTH Breathe APIs when you mention "breathe": ' +
'1) Main HR API - kudos, leave requests, employees, documents, absences, holidays ' +
'2) ELMO Roster API - shifts, rosters, punch clock, time tracking, timesheets. ' +
'Returns comprehensive results from all relevant APIs. ' +
'Example: feature="timesheets on breathe" or feature="kudos on breathe"',
inputSchema: {
type: 'object',
properties: {
swaggerUrl: {
type: 'string',
description: 'URL of the Swagger/OpenAPI specification. OPTIONAL for Breathe queries - auto-provided',
},
swaggerHeaders: {
type: 'object',
description: 'Optional headers for authenticated Swagger endpoints',
additionalProperties: { type: 'string' },
},
feature: {
type: 'string',
description: 'The Breathe HR feature to explain (e.g., "kudos on breathe", "timesheets", "leave requests", "shift scheduling")',
},
platform: {
type: 'string',
enum: ['react', 'react-native', 'nextjs', 'ruby', 'both'],
description: 'Target platform for code examples',
default: 'both',
},
},
required: ['feature'],
},
},
{
name: 'api_request',
description: 'Make HTTP API requests with full control over method, headers, and data',
inputSchema: {
type: 'object',
properties: {
url: {
type: 'string',
description: 'The full URL to make the request to',
},
method: {
type: 'string',
enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
description: 'HTTP method to use',
},
headers: {
type: 'object',
description: 'Optional headers to include in the request',
additionalProperties: { type: 'string' },
},
params: {
type: 'object',
description: 'Optional URL query parameters',
additionalProperties: { type: 'string' },
},
data: {
type: 'object',
description: 'Optional request body data (for POST, PUT, PATCH)',
},
timeout: {
type: 'number',
description: 'Request timeout in milliseconds',
},
},
required: ['url', 'method'],
},
},
{
name: 'parse_swagger',
description: 'Parse a Swagger/OpenAPI specification from a URL or JSON object',
inputSchema: {
type: 'object',
properties: {
url: {
type: 'string',
description: 'URL to fetch the Swagger spec from',
},
spec: {
type: 'object',
description: 'Swagger spec as JSON object (alternative to URL)',
},
headers: {
type: 'object',
description: 'Optional headers for authenticated endpoints',
additionalProperties: { type: 'string' },
},
generateTypes: {
type: 'boolean',
description: 'Whether to generate TypeScript types',
default: true,
},
outputPath: {
type: 'string',
description: 'Path to save generated types',
},
},
},
},
{
name: 'generate_api_client',
description: 'Generate Breathe HR API client code for React, React Native, Next.js, or Ruby. ' +
'Works with Breathe HR Main API and ELMO Roster API when properly configured.',
inputSchema: {
type: 'object',
properties: {
swaggerUrl: {
type: 'string',
description: 'URL of the Swagger/OpenAPI specification for your Breathe HR instance',
},
swaggerHeaders: {
type: 'object',
description: 'Optional headers for authenticated Swagger endpoints',
additionalProperties: { type: 'string' },
},
platform: {
type: 'string',
enum: ['react', 'react-native', 'nextjs', 'ruby'],
description: 'Target platform for code generation',
},
outputDir: {
type: 'string',
description: 'Directory to output generated code',
},
baseUrl: {
type: 'string',
description: 'Override base URL for API calls',
},
authType: {
type: 'string',
enum: ['none', 'bearer', 'api-key', 'oauth'],
description: 'Authentication type to implement',
default: 'none',
},
features: {
type: 'object',
description: 'Optional features to include',
properties: {
hooks: {
type: 'boolean',
description: 'Generate React hooks for API calls',
default: true,
},
errorHandling: {
type: 'boolean',
description: 'Include error handling utilities',
default: true,
},
caching: {
type: 'boolean',
description: 'Include caching support',
default: false,
},
validation: {
type: 'boolean',
description: 'Include request/response validation',
default: true,
},
},
},
},
required: ['swaggerUrl', 'platform', 'outputDir'],
},
},
];
//# sourceMappingURL=index.js.map