A Quick Way to Create an MCP Server with StreamableHTTP
transport implementation from OpenAPI docs.
This server provides a standardized way to interact with model services through a RESTful API interface. It implements the Model Context Protocol (MCP) and is designed to be easily configurable. Simply set up your .env
file, and the server is ready to run.
It implements the Model Context Protocol (MCP) specification and supports OpenAPI documentation.
- OpenAPI 3.0.0 compliant API documentation
- Model service API documentation retrieval
- Model service invocation with parameter handling
- TypeScript implementation for type safety
- Node.js (v20 or higher)
- npm (v6 or higher)
-
Clone the repository:
git clone https://github.com/oneWalker/openapi-mcp-server.git cd openapi-mcp-server
-
Install dependencies:
npm install
-
Configure your environment: Create a
.env
file in the project root and add your configuration. See the Configuration section for details. -
Run the server:
npm run build npm run start
- Clone the repository
- Install dependencies:
npm install
npm run build
npm run watch
npm run start
Create a .env
file in the root of the project to configure the server.
# The base URL for the original API server
BASE_SERVER_URL= https://api.example.com
# The path to the OpenAPI specification file (can be a local file or a URL).
OPENAPI_PATH=./example.yaml or ./example.json # example.yaml is just for demo
# The port for the MCP server to run on
PORT=8000
GET /api/model/services/{ID}
Retrieves the API documentation for a specific model service.
Parameters:
ID
(path, required): Model service IDauthorization
(header, required): Bearer token for authentication
POST /api/model/services/
Invokes a specific model service with provided parameters.
Parameters:
id
(path, required): Model service ID
Request Body:
{
"id": "123"
}
openapi-mcp-server/
├── src/ # Source code
├── build/ # Compiled JavaScript files
├── example.yaml # OpenAPI specification
├── package.json # Project configuration
└── tsconfig.json # TypeScript configuration
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
Please see the CONTRIBUTING.md
file for details on our code of conduct, and the process for submitting pull requests to us.
We use GitHub Issues to track public bugs. Report a bug by opening a new issue; it's that easy!
openapi-mcp-generator
: OpenAPI specification generator- Note: This project requires a pending fix from the
openapi-mcp-generator
library. See this pull request.
- Note: This project requires a pending fix from the
@modelcontextprotocol/sdk
: MCP SDK for protocol implementationexpress
: Web frameworkdotenv
: Environment variable managementgot
: HTTP client
TypeScript
@types/express
@types/node
MIT License - See LICENSE file for details