api2ai 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -54
- package/package.json +238 -20
- package/.claude/settings.local.json +0 -7
- package/bun.lock +0 -17
- package/example-petstore/.env.example +0 -14
- package/example-petstore/README.md +0 -168
- package/example-petstore/bun.lock +0 -1127
- package/example-petstore/package.json +0 -19
- package/example-petstore/src/http-client.js +0 -120
- package/example-petstore/src/index.js +0 -659
- package/example-petstore/src/tools-config.js +0 -247
- package/example.js +0 -164
- package/generate-mcp-use-server.js +0 -864
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
# petstore-api
|
|
2
|
-
|
|
3
|
-
MCP server auto-generated from OpenAPI specification using the [mcp-use](https://mcp-use.com) framework.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- 🛠️ **19 API Tools** - All operations from the OpenAPI spec
|
|
8
|
-
- 🔍 **Built-in Inspector** - Test tools at `/inspector`
|
|
9
|
-
- 📡 **Streamable HTTP** - Modern MCP transport
|
|
10
|
-
- 🔐 **Authentication Support** - Bearer tokens & custom headers
|
|
11
|
-
- 🎨 **UI Widgets** - Compatible with ChatGPT and MCP-UI
|
|
12
|
-
|
|
13
|
-
## Quick Start
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
# Install dependencies
|
|
17
|
-
npm install
|
|
18
|
-
|
|
19
|
-
# Configure environment
|
|
20
|
-
cp .env.example .env
|
|
21
|
-
# Edit .env with your API credentials
|
|
22
|
-
|
|
23
|
-
# Start the server
|
|
24
|
-
npm start
|
|
25
|
-
|
|
26
|
-
# Or with hot reload
|
|
27
|
-
npm run dev
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Then open http://localhost:3000/inspector to test your tools!
|
|
31
|
-
|
|
32
|
-
## Environment Variables
|
|
33
|
-
|
|
34
|
-
| Variable | Description | Default |
|
|
35
|
-
|----------|-------------|---------|
|
|
36
|
-
| `PORT` | Server port | 3000 |
|
|
37
|
-
| `NODE_ENV` | Environment (development/production) | development |
|
|
38
|
-
| `API_BASE_URL` | Base URL for API requests | /api/v3 |
|
|
39
|
-
| `API_KEY` | Bearer token for Authorization header | - |
|
|
40
|
-
| `API_AUTH_HEADER` | Custom auth header (format: `Header:value`) | - |
|
|
41
|
-
| `MCP_URL` | Public MCP server URL (for widgets) | http://localhost:3000 |
|
|
42
|
-
| `ALLOWED_ORIGINS` | Allowed origins in production (comma-separated) | - |
|
|
43
|
-
|
|
44
|
-
## Connect to Claude Desktop
|
|
45
|
-
|
|
46
|
-
Add to your Claude Desktop configuration:
|
|
47
|
-
|
|
48
|
-
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
49
|
-
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
50
|
-
|
|
51
|
-
```json
|
|
52
|
-
{
|
|
53
|
-
"mcpServers": {
|
|
54
|
-
"petstore-api": {
|
|
55
|
-
"url": "http://localhost:3000/mcp"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Connect to ChatGPT
|
|
62
|
-
|
|
63
|
-
This server supports the OpenAI Apps SDK. Configure your ChatGPT integration to use:
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
http://localhost:3000/mcp
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Available Tools
|
|
70
|
-
|
|
71
|
-
| Tool | Method | Path | Description |
|
|
72
|
-
|------|--------|------|-------------|
|
|
73
|
-
| `addPet` | POST | /pet | Add a new pet to the store. |
|
|
74
|
-
| `updatePet` | PUT | /pet | Update an existing pet. |
|
|
75
|
-
| `findPetsByStatus` | GET | /pet/findByStatus | Finds Pets by status. |
|
|
76
|
-
| `findPetsByTags` | GET | /pet/findByTags | Finds Pets by tags. |
|
|
77
|
-
| `getPetById` | GET | /pet/{petId} | Find pet by ID. |
|
|
78
|
-
| `updatePetWithForm` | POST | /pet/{petId} | Updates a pet in the store with form data. |
|
|
79
|
-
| `deletePet` | DELETE | /pet/{petId} | Deletes a pet. |
|
|
80
|
-
| `uploadFile` | POST | /pet/{petId}/uploadImage | Uploads an image. |
|
|
81
|
-
| `getInventory` | GET | /store/inventory | Returns pet inventories by status. |
|
|
82
|
-
| `placeOrder` | POST | /store/order | Place an order for a pet. |
|
|
83
|
-
| `getOrderById` | GET | /store/order/{orderId} | Find purchase order by ID. |
|
|
84
|
-
| `deleteOrder` | DELETE | /store/order/{orderId} | Delete purchase order by identifier. |
|
|
85
|
-
| `createUser` | POST | /user | Create user. |
|
|
86
|
-
| `createUsersWithListInput` | POST | /user/createWithList | Creates list of users with given input array. |
|
|
87
|
-
| `loginUser` | GET | /user/login | Logs user into the system. |
|
|
88
|
-
| `logoutUser` | GET | /user/logout | Logs out current logged in user session. |
|
|
89
|
-
| `getUserByName` | GET | /user/{username} | Get user by user name. |
|
|
90
|
-
| `updateUser` | PUT | /user/{username} | Update user resource. |
|
|
91
|
-
| `deleteUser` | DELETE | /user/{username} | Delete user resource. |
|
|
92
|
-
|
|
93
|
-
## API Endpoints
|
|
94
|
-
|
|
95
|
-
| Endpoint | Description |
|
|
96
|
-
|----------|-------------|
|
|
97
|
-
| `GET /inspector` | Interactive tool testing UI |
|
|
98
|
-
| `POST /mcp` | MCP protocol endpoint |
|
|
99
|
-
| `GET /sse` | Server-Sent Events endpoint |
|
|
100
|
-
| `GET /health` | Health check endpoint |
|
|
101
|
-
|
|
102
|
-
## Project Structure
|
|
103
|
-
|
|
104
|
-
```
|
|
105
|
-
petstore-api/
|
|
106
|
-
├── .env # Environment configuration
|
|
107
|
-
├── .env.example # Example environment file
|
|
108
|
-
├── package.json # Dependencies
|
|
109
|
-
├── README.md # This file
|
|
110
|
-
└── src/
|
|
111
|
-
├── index.js # Main server with MCP tool registrations
|
|
112
|
-
├── http-client.js # HTTP utilities for API calls
|
|
113
|
-
└── tools-config.js # Tool configurations from OpenAPI spec
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## How It Works
|
|
117
|
-
|
|
118
|
-
Each tool is registered using the proper MCP format:
|
|
119
|
-
|
|
120
|
-
```javascript
|
|
121
|
-
server.tool(
|
|
122
|
-
{
|
|
123
|
-
name: 'getPetById',
|
|
124
|
-
description: 'Find pet by ID',
|
|
125
|
-
schema: z.object({
|
|
126
|
-
petId: z.number().int().describe('ID of pet to return'),
|
|
127
|
-
}),
|
|
128
|
-
},
|
|
129
|
-
async (params) => {
|
|
130
|
-
// Fetch data from the API
|
|
131
|
-
const result = await executeRequest(toolConfig, params, apiConfig);
|
|
132
|
-
|
|
133
|
-
// Return MCP content (text or object)
|
|
134
|
-
return result.ok ? object(result.data) : text(`Error: ${result.status}`);
|
|
135
|
-
}
|
|
136
|
-
);
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
## Production Deployment
|
|
140
|
-
|
|
141
|
-
### Docker
|
|
142
|
-
|
|
143
|
-
```dockerfile
|
|
144
|
-
FROM node:20-alpine
|
|
145
|
-
WORKDIR /app
|
|
146
|
-
COPY package*.json ./
|
|
147
|
-
RUN npm ci --only=production
|
|
148
|
-
COPY . .
|
|
149
|
-
ENV NODE_ENV=production
|
|
150
|
-
EXPOSE 3000
|
|
151
|
-
CMD ["npm", "start"]
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### PM2
|
|
155
|
-
|
|
156
|
-
```bash
|
|
157
|
-
pm2 start src/index.js --name petstore-api
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## Source
|
|
161
|
-
|
|
162
|
-
- **OpenAPI Spec**: `https://petstore3.swagger.io/api/v3/openapi.json`
|
|
163
|
-
- **Generated**: 2025-12-31T01:39:23.989Z
|
|
164
|
-
- **Framework**: [mcp-use](https://mcp-use.com)
|
|
165
|
-
|
|
166
|
-
## License
|
|
167
|
-
|
|
168
|
-
MIT
|