Labsco
ssossan logo

MCP OpenAPI Connector

โ˜… 3

from ssossan

Connect to any OpenAPI-based API with built-in OAuth2 authentication management.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredAdvanced setup

MCP OpenAPI Connector

A unified Model Context Protocol (MCP) server for connecting OpenAPI-based APIs with built-in authentication management. This project enables Claude Desktop, Cursor, and other MCP-compatible clients to interact with authenticated OpenAPI-based APIs without requiring separate proxy servers.

Features

  • Single Process Architecture: No separate proxy server needed
  • Built-in OAuth2 Authentication: Automatic token management and refresh
  • OpenAPI Integration: Automatically generate MCP tools from OpenAPI/Swagger specifications
  • Extensible Tool System: Easy to add custom tools and resources
  • Error Handling: Automatic retry and authentication error recovery
  • Simple Configuration: Single configuration file for all settings
  • Multiple API Support: Easily adapt to any OAuth2-based API

Publishing to npm

For maintainers:

npm run build
npm test
npm publish --access public

Development

Available Scripts

npm run dev          # Development mode with tsx
npm run build        # Compile TypeScript to JavaScript
npm start            # Build and run production version
npm run test         # Build and run test server
npm run test:dev     # Run test server in development mode
npm run typecheck    # Type check without compilation
npm run clean        # Remove build output

TypeScript Development

This project is built with TypeScript for better type safety and development experience:

  • Source code: src/ directory
  • Build output: dist/ directory
  • Type definitions: Automatically generated .d.ts files

Architecture

Claude Desktop โ†” MCP Server (stdio) โ†’ OpenAPI-based API
                    โ†“
             TokenManager
           (OAuth2 handling)

Key Components

  • src/mcp-openapi-connector.ts - Main server entry point
  • src/lib/token-manager.ts - OAuth2 token management with caching
  • src/lib/saas-client.ts - HTTP client with automatic authentication
  • src/lib/mcp-handler.ts - MCP protocol handling and tool registration
  • src/lib/openapi-loader.ts - OpenAPI specification parser and tool generator
  • src/types/ - TypeScript type definitions

Migration from v1.x

If you're using the previous gateway-based version:

  1. Remove the proxy server configuration
  2. Update your Claude Desktop config to point directly to this server
  3. Use the same environment variables (no changes needed)

Example: Using with a Generic OpenAPI-based API

See the config/openapi-example.json file for a sample OpenAPI specification that demonstrates how to structure your API for MCP integration.