Update README with npm installation and usage instructions
This commit is contained in:
parent
335643b45b
commit
7023084ede
74
README.md
74
README.md
@ -1,7 +1,10 @@
|
|||||||
# OpenAPI to MCP
|
# OpenAPI to MCP Generator
|
||||||
|
|
||||||
A command-line tool that generates Model Context Protocol (MCP) server code from OpenAPI specifications. This tool helps you quickly create an MCP server that acts as a bridge between LLMs (Large Language Models) and your API.
|
A command-line tool that generates Model Context Protocol (MCP) server code from OpenAPI specifications. This tool helps you quickly create an MCP server that acts as a bridge between LLMs (Large Language Models) and your API.
|
||||||
|
|
||||||
|
[](https://www.npmjs.com/package/openapi-mcp-generator)
|
||||||
|
[](https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Automatic Tool Generation**: Converts each API endpoint in your OpenAPI spec into an MCP tool
|
- **Automatic Tool Generation**: Converts each API endpoint in your OpenAPI spec into an MCP tool
|
||||||
@ -13,20 +16,14 @@ A command-line tool that generates Model Context Protocol (MCP) server code from
|
|||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Clone this repository
|
# Install globally from npm
|
||||||
git clone https://github.com/yourusername/openapi-to-mcp.git
|
npm install -g openapi-mcp-generator
|
||||||
|
|
||||||
# Navigate to the project directory
|
# Or with yarn
|
||||||
cd openapi-to-mcp
|
yarn global add openapi-mcp-generator
|
||||||
|
|
||||||
# Install dependencies
|
# Or with pnpm
|
||||||
npm install
|
pnpm add -g openapi-mcp-generator
|
||||||
|
|
||||||
# Make the script executable
|
|
||||||
chmod +x index.js
|
|
||||||
|
|
||||||
# Optionally, install globally
|
|
||||||
npm install -g .
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@ -34,13 +31,7 @@ npm install -g .
|
|||||||
Generate an MCP server from an OpenAPI specification:
|
Generate an MCP server from an OpenAPI specification:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./index.js --openapi path/to/openapi.json --output ./my-mcp-server
|
openapi-mcp --openapi path/to/openapi.json --output ./my-mcp-server
|
||||||
```
|
|
||||||
|
|
||||||
Or if installed globally:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
openapi-to-mcp --openapi path/to/openapi.json --output ./my-mcp-server
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Command Line Options
|
### Command Line Options
|
||||||
@ -60,19 +51,19 @@ openapi-to-mcp --openapi path/to/openapi.json --output ./my-mcp-server
|
|||||||
Generate from a local OpenAPI file:
|
Generate from a local OpenAPI file:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./index.js --openapi ./specs/petstore.json --output ./petstore-mcp
|
openapi-mcp --openapi ./specs/petstore.json --output ./petstore-mcp
|
||||||
```
|
```
|
||||||
|
|
||||||
Generate from a remote OpenAPI URL:
|
Generate from a remote OpenAPI URL:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./index.js --openapi https://petstore3.swagger.io/api/v3/openapi.json --output ./petstore-mcp
|
openapi-mcp --openapi https://petstore3.swagger.io/api/v3/openapi.json --output ./petstore-mcp
|
||||||
```
|
```
|
||||||
|
|
||||||
Specify a WebSocket transport:
|
Specify a WebSocket transport:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./index.js --openapi ./specs/petstore.json --transport websocket --port 8080
|
openapi-mcp --openapi ./specs/petstore.json --transport websocket --port 8080
|
||||||
```
|
```
|
||||||
|
|
||||||
## Generated Files
|
## Generated Files
|
||||||
@ -116,11 +107,46 @@ After generating your MCP server:
|
|||||||
npm start
|
npm start
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Programmatic Usage
|
||||||
|
|
||||||
|
You can also use the package programmatically in your Node.js projects:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const { generateMcpServer } = require('openapi-mcp-generator');
|
||||||
|
|
||||||
|
// Using async/await
|
||||||
|
async function generate() {
|
||||||
|
try {
|
||||||
|
const result = await generateMcpServer({
|
||||||
|
openapi: './specs/petstore.json',
|
||||||
|
output: './petstore-mcp',
|
||||||
|
transport: 'http',
|
||||||
|
port: 3000
|
||||||
|
});
|
||||||
|
console.log(`MCP server generated at: ${result.outputPath}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Generation failed:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
generate();
|
||||||
|
```
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Node.js 16.x or higher
|
- Node.js 16.x or higher
|
||||||
- npm 7.x or higher
|
- npm 7.x or higher
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
||||||
|
|
||||||
|
1. Fork the repository
|
||||||
|
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
||||||
|
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
||||||
|
4. Push to the branch (`git push origin feature/amazing-feature`)
|
||||||
|
5. Open a Pull Request
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT
|
MIT
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user