|
1 | 1 | # MCP-OpenAPI Model Context Protocol wrapper for OpenAPI compliant endpoints |
| 2 | +This is a Proof-of-Concept project implementing a multi-purpose OpenAPI MCP Server that can be used to proxy any OpenAPI compliant API backend with an MCP Server protocol |
2 | 3 |
|
3 | | -The main application mcp-openapi provides a generic MCP Server wrapper over any OpenAPI compliant endpoints. It will, given the OpenAPI specs, generate MCP tools & resources with some sensible defaults and overridable via configuration. It will also allow definition of additional MCP Prompts, via config. It will hosts the MCP end points for all these MCP capabilities and integrate with the backend APIs as per the configuration. |
| 4 | +The project also comes with an example OpenAPI application hosting some sample banking APIs with some manufactured data, a demo MCP Client application that provides an example use-case of an MCP Client interacting with the MCP Server proxying some sample problems between the sample banking APIs and an LLM (hosting via LMStudio). |
4 | 5 |
|
5 | | -This project provides comprehensive set of apps demonstrating how to use the mcp-openapi MCP Server over existing APIs via the sample banking api app. |
| 6 | +Demo/Testing can also be done without the demo MCP application or LM Studio via integrating the MCP server with an MCP enabled tools such as Cursor IDE (tested) or Windsurf (not tested), etc. |
6 | 7 |
|
7 | | -The mcp-test-client is an example MCP client taking in some pre-baked prompts containing some common, but manufactured, banking scenarios and connecting & orchestrating between the scenarios, the MCP server fronting the sample banking APIs and an LLM. |
| 8 | +All the above are structured under 3 separate folders under this project: |
8 | 9 |
|
9 | | -The sample-banking-api and mcp-test-client app are not expected to be re-used and is for demo purposes only. |
| 10 | +1. **mcp-openapi** is the reference implementation of the OpenAPI MCP proxy |
| 11 | +2. **mcp-test-client** is the demo test client with some sample questions based on the manufactured data in the sample banking app |
| 12 | +3. **sample-banking-api** is the sample banking application with a number of OpenAPI endpoints and manufactured data |
10 | 13 |
|
11 | 14 | NOTE: This mcp-openapi app is not a replacement for https://github.com/ReAPI-com/mcp-openapi project that is enabling IDEs like Cursor to connect to open api specs to support api development. |
12 | 15 |
|
13 | 16 | ## 🔄 Integration Flow |
14 | 17 |
|
15 | 18 | ``` |
16 | | -Sample Banking API ←→ MCP OpenAPI Server ←→ Demo/Test Banking MCP Client ←→ LLM/AI Application |
| 19 | +Sample Banking API ←→ MCP OpenAPI Server ←→ Demo/Test Banking MCP Client ←→ LLM via LM Studio |
17 | 20 | ``` |
| 21 | +or |
18 | 22 |
|
19 | | -1. **Sample Banking API** provides some RESTful banking services with authentication |
20 | | -2. **MCP OpenAPI Server** wraps the API as MCP tools and resources |
21 | | -3. **Test/Demo MCP Client** consumes the MCP server for AI integration |
22 | | -4. **LLM/AI Application** uses the tools through the MCP protocol - for the demo/test we have implemented LM Studio integration |
| 23 | +``` |
| 24 | +Sample Banking API ←→ MCP OpenAPI Server ←→ Cursor IDE |
| 25 | +``` |
23 | 26 |
|
24 | 27 |
|
25 | 28 | ## 🏗️ Project Structure |
26 | 29 |
|
27 | 30 | This repository contains three applications: |
28 | 31 |
|
29 | 32 | ### 🔌 [`mcp-openapi/`](./mcp-openapi/) |
30 | | -This contain the main application, a **generic, configurable MCP server** that automatically generates MCP tools and resources from OpenAPI specifications: |
| 33 | +This contain the main application, a **multi-purpose, configurable MCP server** that automatically generates MCP tools and resources from OpenAPI specifications: |
31 | 34 | - Automatic tool/resource generation from OpenAPI specs |
32 | 35 | - Token passthrough authentication |
33 | | -- Custom prompt templates |
| 36 | +- Addition of custom prompt templates |
34 | 37 | - Multiple deployment modes (stdio/HTTP) |
35 | | -- Comprehensive test coverage (61/61 tests passing) |
36 | 38 |
|
37 | 39 | **Quick Start:** |
38 | 40 | ```bash |
39 | 41 | cd mcp-openapi |
40 | 42 | npm install |
41 | | -npm run dev -- --specs ./examples/specs --config ./examples/mcp-config.json --verbose |
| 43 | +npm run build |
| 44 | +npm run dev |
42 | 45 | ``` |
43 | 46 |
|
| 47 | +The "dev" startup is pre-configured to integrate with the sample banking api app. Please refer to the README in the app folder for more details. |
44 | 48 |
|
45 | 49 | ### 📊 [`sample-banking-api/`](./sample-banking-api/) |
46 | 50 | An example **Sample banking API implementation** with: |
47 | 51 | - RESTful endpoints for payments, payees, and products |
48 | 52 | - basic JWT authentication and validation |
49 | 53 | - OpenAPI specifications |
50 | | -- Comprehensive test suite |
51 | 54 | - Manufactured data, via JSON files, to support the app |
52 | 55 | - Purpose of this is to support the demo and usage of the main application |
53 | 56 |
|
54 | 57 | **Quick Start:** |
55 | 58 | ```bash |
56 | 59 | cd sample-banking-api |
57 | 60 | npm install |
58 | | -npm run server:dev |
| 61 | +npm start |
59 | 62 | ``` |
60 | 63 |
|
61 | | -### 🧪 [`mcp-test-client/`](./mcp-test-client/) |
62 | | -An example **test client application, including an MCP Client** for validating MCP server functionality over the sample banking app. The sample client app will also integrate with an LLM, LM Studio integration provided, to demo the MCP flow. |
| 64 | +Please refer to the README in the app folder for more details. |
63 | 65 |
|
| 66 | +### 🧪 [`mcp-test-client/`](./mcp-test-client/) |
| 67 | +A **Demo MCP client application** for validating MCP server functionality over the sample banking app. The sample client app will also integrate with an LLM, via a local LM Studio integration, to demo the MCP flow. |
64 | 68 |
|
65 | | -## 🚀 Getting Started |
| 69 | +This requires LM Studio to be running locally on default port 1234 (i.e. http://localhost:1234), but configurable if it is running on different port. LM Studio must be loaded with an LLM that supports tool calling (tested on meta-llama-3.1-8b-instruct model). |
66 | 70 |
|
67 | | -### 1. Start the Banking API |
68 | | -```bash |
69 | | -cd sample-banking-api |
70 | | -npm install |
71 | | -npm run server:dev |
72 | | -# Server runs on http://localhost:3001 |
73 | | -``` |
74 | | - |
75 | | -### 2. Start the MCP Server |
| 71 | +**Quick Start:** |
76 | 72 | ```bash |
77 | | -cd mcp-openapi |
| 73 | +cd mcp-test-client |
78 | 74 | npm install |
79 | | -npm run dev -- --specs ./examples/specs --config ./examples/mcp-config.json --verbose |
80 | | -# MCP server runs on http://localhost:4000 and will connect to banking API to serve requests |
| 75 | +npm start |
81 | 76 | ``` |
| 77 | +This will launch the demo mcp client which is a CLI menu driven app with a few pre-configured test scenarios against the manufactured data in the sample banking app. |
82 | 78 |
|
83 | | -### 3. Start/Load you LLM in LM Studio |
84 | | -Load and start your LLM in LM Studio. This project assumes the LM Studio API will be running on http://localhost:1234 |
85 | | - |
86 | | -If you need to change the URL, update the /examples/mcp-config.json file in the mcp-openapi app and restart it. |
87 | | - |
88 | | -### 4. Testing or running the demo |
89 | | -Once you've started all the different moving parts to test/demo. Refer to the mcp-client-test Readme to launch the demo/client. It is menu driven with a number of pre-build test scenarios using the manufactured data in the sample banking api app. |
| 79 | +Please refer to the README in the app folder for more details. |
90 | 80 |
|
91 | 81 | ## 📋 Features |
92 | 82 |
|
93 | | -### Banking API Features |
94 | | -- ✅ Complete CRUD operations for payments, payees, products |
| 83 | +### Sample Banking API Features |
| 84 | +- ✅ Sample data with APIs for payments, payees, products |
95 | 85 | - ✅ JWT authentication with bearer tokens |
96 | 86 | - ✅ OpenAPI 3.0 specifications |
97 | 87 | - ✅ Request validation and error handling |
@@ -135,11 +125,8 @@ npm test |
135 | 125 | ## 🎯 Use Cases |
136 | 126 |
|
137 | 127 | This project demonstrates: |
138 | | -- **API Wrapping**: How to wrap existing REST APIs as MCP servers |
139 | | -- **Authentication Patterns**: Token passthrough for secure API access |
140 | | -- **Error Handling**: Production-ready error handling with security monitoring |
141 | | -- **Testing Strategies**: Comprehensive test coverage for API wrappers |
142 | | -- **Development Workflow**: Local development with hot reloading |
| 128 | +- **Multi-purpose API Wrapping**: How to wrap existing REST APIs with an MCP server |
| 129 | +- **MCP Prompts augmentation**: Adding custom MCP prompts to enable higher order/composite usage of those API via MCP |
143 | 130 |
|
144 | 131 | ## 🤝 Contributing |
145 | 132 |
|
|
0 commit comments