Configuration Overview
OpenAPI MCP Server supports flexible configuration through multiple methods. Configuration options can be provided via:
- Environment Variables - Best for deployment and secrets management
- Command Line Arguments - Ideal for CLI usage and testing
- Configuration Objects - For library usage in TypeScript/JavaScript
Configuration Priority
Configuration is applied in the following order (highest to lowest priority):
- Command line arguments
- Environment variables
- Default values
Complete Configuration Interface
The complete TypeScript interface for OpenAPI MCP Server configuration:
interface IOpenAPIServerConfig {
// Required Configuration
apiBaseUrl: string; // Base URL for API endpoints
// OpenAPI Specification
openApiSpec?: string; // Path, URL, or inline content
specInputMethod?: SpecInputMethod; // 'url' | 'file' | 'stdin' | 'inline'
// Server Identity
name?: string; // Server name (default: 'openapi-mcp-server')
version?: string; // Server version (default: '1.0.0')
namespace?: string; // Namespace for the MCP server tools
// Authentication (choose one)
headers?: Record; // Static headers
authProvider?: IAuthProvider; // Dynamic authentication
// Transport Configuration
transportType?: TransportType; // 'stdio' | 'http' (default: 'stdio')
httpPort?: number; // HTTP port (default: 3000)
httpHost?: string; // HTTP host (default: '127.0.0.1')
endpointPath?: string; // HTTP endpoint (default: '/mcp')
// Tool Management
toolsMode?: ToolsMode; // 'all' | 'dynamic' | 'explicit'
includeTools?: string[]; // Specific tools to include
includeTags?: string[]; // OpenAPI tags to include
includeResources?: string[]; // Resource paths to include
includeOperations?: string[]; // HTTP methods to include
// Options
disableAbbreviation?: boolean; // Disable tool name abbreviation
debug?: boolean; // Enable debug logging
}
Environment Variables
All configuration options can be set via environment variables. This is the recommended approach for production deployments:
Required Variables
| Variable |
Description |
Example |
API_BASE_URL |
Base URL for the API endpoints |
https://api.example.com |
OpenAPI Specification
| Variable |
Description |
Example |
OPENAPI_SPEC_PATH |
Path or URL to OpenAPI specification |
./api-spec.yaml
https://api.example.com/openapi.json |
OPENAPI_SPEC_FROM_STDIN |
Read spec from standard input |
true |
OPENAPI_SPEC_INLINE |
Provide spec content directly |
{"openapi":"3.0.0",...} |
Authentication
| Variable |
Description |
Example |
API_HEADERS |
Comma-separated key:value pairs for API headers |
Authorization:Bearer token123,X-API-Key:key456 |
Server Configuration
| Variable |
Description |
Default |
Example |
SERVER_NAME |
Name for the MCP server |
openapi-mcp-server |
my-api-server |
SERVER_VERSION |
Version of the server |
1.0.0 |
2.1.0 |
NAMESPACE |
Namespace for the MCP server tools |
None |
my-api |
Transport Configuration
| Variable |
Description |
Default |
Options |
TRANSPORT_TYPE |
Transport type to use |
stdio |
stdio, http |
HTTP_PORT |
Port for HTTP transport |
3000 |
Any valid port number |
HTTP_HOST |
Host for HTTP transport |
127.0.0.1 |
0.0.0.0, localhost |
ENDPOINT_PATH |
Endpoint path for HTTP transport |
/mcp |
/api/mcp |
Tool Management
| Variable |
Description |
Default |
Options |
TOOLS_MODE |
Tools loading mode |
all |
all, dynamic, explicit |
DISABLE_ABBREVIATION |
Disable tool name abbreviation |
false |
true, false |
Environment Variables Example
# Required
export API_BASE_URL="https://api.github.com"
# OpenAPI Specification
export OPENAPI_SPEC_PATH="https://api.github.com/openapi.json"
# Authentication
export API_HEADERS="Authorization:Bearer ghp_xxxxxxxxxxxx,Accept:application/vnd.github.v3+json"
# Server Configuration
export SERVER_NAME="github-mcp-server"
export SERVER_VERSION="1.0.0"
export NAMESPACE="github"
# Transport
export TRANSPORT_TYPE="http"
export HTTP_PORT="8080"
export HTTP_HOST="0.0.0.0"
# Tool Management
export TOOLS_MODE="all"
export DISABLE_ABBREVIATION="false"
# Run the server
npx @lucid-spark/openapi-mcp-server openapi-mcp-server
Command Line Arguments
All configuration options are available as command line arguments. This is ideal for CLI usage and testing:
Basic Usage
npx @lucid-spark/openapi-mcp-server [options]
Required Arguments
| Argument |
Description |
Example |
--api-base-url <url> |
Base URL for the API endpoints |
--api-base-url https://api.example.com |
OpenAPI Specification Arguments
| Argument |
Description |
Example |
--openapi-spec <path-or-url> |
Path or URL to OpenAPI specification |
--openapi-spec ./api-spec.yaml |
--spec-from-stdin |
Read OpenAPI spec from standard input |
--spec-from-stdin |
--spec-inline <content> |
Provide OpenAPI spec content directly |
--spec-inline '{"openapi":"3.0.0",...}' |
Authentication Arguments
| Argument |
Description |
Example |
--headers <headers> |
Comma-separated key:value pairs for API headers |
--headers "Authorization:Bearer token,X-API-Key:key" |
Server Arguments
| Argument |
Description |
Default |
--server-name <name> |
Name for the MCP server |
openapi-mcp-server |
--server-version <version> |
Version of the server |
1.0.0 |
Transport Arguments
| Argument |
Description |
Default |
--transport <type> |
Transport type: stdio or http |
stdio |
--port <port> |
Port for HTTP transport |
3000 |
--host <host> |
Host for HTTP transport |
127.0.0.1 |
--path <path> |
Endpoint path for HTTP transport |
/mcp |
Tool Management Arguments
| Argument |
Description |
Default |
--tools <mode> |
Tools loading mode: all, dynamic, or explicit |
all |
--tool <tool> |
Include specific tool ID or name (repeatable) |
- |
--tag <tag> |
Include tools with specific OpenAPI tag (repeatable) |
- |
--resource <resource> |
Include tools under specific resource path (repeatable) |
- |
--operation <method> |
Include tools for specific HTTP methods (repeatable) |
- |
Other Arguments
| Argument |
Description |
Default |
--disable-abbreviation |
Disable tool name abbreviation |
false |
--debug |
Enable debug logging |
false |
--help |
Display help information |
- |
--version |
Display version information |
- |
Complete CLI Example
npx @lucid-spark/openapi-mcp-server openapi-mcp-server \
--api-base-url https://api.github.com \
--openapi-spec https://api.github.com/openapi.json \
--headers "Authorization:Bearer ghp_xxxxxxxxxxxx,Accept:application/vnd.github.v3+json" \
--server-name "github-mcp-server" \
--server-version "1.0.0" \
--transport http \
--port 8080 \
--host 0.0.0.0 \
--path /mcp \
--tools all \
--tag public \
--operation GET \
--operation POST \
--debug
Library Configuration
When using OpenAPI MCP Server as a library, configuration is provided through TypeScript/JavaScript objects:
Basic Configuration
import { OpenAPIServer } from "@lucid-spark/openapi-mcp-server";
const config = {
apiBaseUrl: "https://api.example.com",
openApiSpec: "https://api.example.com/openapi.json",
headers: {
Authorization: "Bearer your-token",
"X-API-Key": "your-api-key"
},
transportType: "stdio" as const
};
const server = new OpenAPIServer(config);
await server.start();
Advanced Configuration with AuthProvider
import { OpenAPIServer, IAuthProvider } from "@lucid-spark/openapi-mcp-server";
class CustomAuthProvider implements IAuthProvider {
async getAuthHeaders(): Promise> {
// Dynamic authentication logic
return {
Authorization: `Bearer ${await this.getValidToken()}`,
"X-Custom-Header": "custom-value"
};
}
async handleAuthError(error: any): Promise {
// Handle auth errors and retry logic
if (error.response?.status === 401) {
await this.refreshToken();
return true; // Retry request
}
return false;
}
}
const config = {
apiBaseUrl: "https://api.example.com",
openApiSpec: "./api-spec.yaml",
specInputMethod: "file" as const,
authProvider: new CustomAuthProvider(),
transportType: "http" as const,
httpPort: 8080,
toolsMode: "all" as const,
includeTags: ["users", "posts"],
debug: true
};
const server = new OpenAPIServer(config);
Configuration Validation
import { validateConfig } from "@lucid-spark/openapi-mcp-server";
// Validate configuration before creating server
try {
const validatedConfig = validateConfig(config);
const server = new OpenAPIServer(validatedConfig);
} catch (error) {
console.error("Configuration validation failed:", error.message);
}
Claude Desktop Configuration
Configure OpenAPI MCP Server for use with Claude Desktop:
Configuration File Location
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
Basic Configuration
{
"mcpServers": {
"openapi": {
"command": "npx",
"args": ["-y", "@lucid-spark/openapi-mcp-server", "openapi-mcp-server"],
"env": {
"API_BASE_URL": "https://api.example.com",
"OPENAPI_SPEC_PATH": "https://api.example.com/openapi.json",
"API_HEADERS": "Authorization:Bearer token123"
}
}
}
}
Configuration with Filtering
{
"mcpServers": {
"github-api": {
"command": "npx",
"args": [
"-y",
"@lucid-spark/openapi-mcp-server",
"openapi-mcp-server",
"--api-base-url",
"https://api.github.com",
"--openapi-spec",
"https://api.github.com/openapi.json",
"--tag",
"public",
"--operation",
"GET",
"--operation",
"POST"
],
"env": {
"GITHUB_TOKEN": "ghp_xxxxxxxxxxxx",
"API_HEADERS": "Authorization:Bearer ${GITHUB_TOKEN},Accept:application/vnd.github.v3+json"
}
}
}
}
Configuration Examples
Public API (No Auth)
export API_BASE_URL="https://jsonplaceholder.typicode.com"
export OPENAPI_SPEC_PATH="https://jsonplaceholder.typicode.com/openapi.json"
npx @lucid-spark/openapi-mcp-server openapi-mcp-server
API with Token Auth
export API_BASE_URL="https://api.github.com"
export OPENAPI_SPEC_PATH="https://api.github.com/openapi.json"
export API_HEADERS="Authorization:Bearer ghp_token,Accept:application/vnd.github.v3+json"
npx @lucid-spark/openapi-mcp-server openapi-mcp-server
HTTP Transport
npx @lucid-spark/openapi-mcp-server openapi-mcp-server \
--api-base-url https://api.example.com \
--openapi-spec ./api-spec.yaml \
--transport http \
--port 3000 \
--host 0.0.0.0
Filtered Tools
npx @lucid-spark/openapi-mcp-server openapi-mcp-server \
--api-base-url https://api.example.com \
--openapi-spec ./api-spec.yaml \
--tools explicit \
--tool GET::users \
--tool POST::users
Configuration Best Practices
🔐 Security
- Store sensitive data in environment variables
- Never commit API keys to version control
- Use IAM roles when possible
- Rotate tokens regularly
📦 Deployment
- Use environment variables for configuration
- Validate configuration at startup
- Use specific server names for identification
- Enable debug mode for troubleshooting
⚡ Performance
- Filter tools to reduce memory usage
- Use local files for large specs when possible
- Disable abbreviation only when necessary
- Monitor tool generation time
🛠️ Development
- Use CLI arguments for quick testing
- Enable debug mode during development
- Test with different tool modes
- Validate OpenAPI specs before deployment