You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-23Lines changed: 48 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,24 @@
1
-
# MCP Server for REST APIs
1
+
# MCP Server for Apache OFBiz®
2
2
3
-
This project provides a prototype implementation of an MCP server that:
3
+
This project provides a prototype implementation of a Model Context Protocol (MCP) server for Apache OFBiz® that:
4
+
5
+
- receives requests from an MCP client (usually hosted in a generative AI application such as Claude Desktop) and forwards those requests to a remote backend via RESTful API endpoints,
6
+
- exposes a tamplate tool that invokes the findProductById OFBiz endpoint.
4
7
5
-
- exposes specific tools,
6
-
- receives requests from an MCP client (usually hosted in a generative AI application such as Claude Desktop),
7
-
- forwards those requests to a remote backend via RESTful API endpoints,
8
-
- implements authorization according to the MCP specifications (OAuth Authorization Code Flow with support for Metadata discovery, Dynamic Client Registration etc...).
9
-
10
-
The server enables generative AI applications to interact with backend systems that expose REST API endpoints, such as **Apache OFBiz** and **Moqui**.
8
+
The server can enable generative AI applications to interact with any backend system that exposes REST API endpoints, such as [**Apache OFBiz**](https://ofbiz.apache.org) or [**Moqui**](https://www.moqui.org).
11
9
12
10
The server is implemented in two versions, one that runs as a local MCP server (stdio transport) and one that runs as a remote MCP server (Streamable HTTP transport).
13
11
14
-
The project is implemented in **TypeScript**, uses the **Anthropic TypeScript SDK**, and requires:
12
+
The project leverages the **Anthropic TypeScript SDK**, and requires:
15
13
16
14
- Node.js
17
15
- npm
18
16
17
+
This software is licensed under the Apache License, Version 2.0.
18
+
19
+
Apache OFBiz® is a trademark of the [Apache Software Foundation](https://www.apache.org)
20
+
21
+
19
22
---
20
23
21
24
## Table of Contents
@@ -36,9 +39,19 @@ The project includes two alternative MCP servers:
36
39
-**Local MCP server** (`src/server-local.ts`) — communicates with the MCP client via stdio transport.
37
40
-**Remote MCP server** (`src/server-remote.ts`) — communicates with the MCP client via MCP Streamable HTTP transport.
38
41
39
-
The servers are modular and dynamically discover MCP tools contained in the `tools` directory.
42
+
The servers dynamically discover MCP tools contained in the `tools` directory.
43
+
44
+
Each tool is defined and implemented in its own file. For example, the sample tool `tools/findProductById.ts` invokes an endpoint in Apache OFBiz to retrieve product information for a given product ID. This works with an out-of-the-box (OOTB) OFBiz instance with the `rest-api` plugin installed.
40
45
41
-
Each tool is defined and implemented in its own file. For example, the sample tool `tools/findProductById.ts` invokes an endpoint in Apache OFBiz to retrieve product information for a given ID. This works with an out-of-the-box (OOTB) OFBiz instance with the `rest-api` plugin installed.
46
+
New tools can be published by simply including their definition files in the `tools` folder.
47
+
48
+
The remote server:
49
+
- is compliant with the latest MCP specifications
50
+
- supports authorization according to the MCP recommendations (OAuth Authorization Code Flow with support for Metadata discovery, Dynamic Client Registration, etc...)
51
+
- supports the token exchange OAuth flow in order to obtain a valid token for the backend system
52
+
- performs token validation with configurable scopes and audience verification
53
+
- provides rate limiting features to protect the MCP server and the backend server from denial of service attacks
54
+
- allows CORS restrictions
42
55
43
56
---
44
57
@@ -47,38 +60,50 @@ Each tool is defined and implemented in its own file. For example, the sample to
47
60
Server configuration is managed via `config/config.json`, which defines:
48
61
49
62
-**`MCP_SERVER_BASE_URL`** — the base URL of the MCP server (Protected Resource Server in OAuth)
50
-
-**`AUTHZ_SERVER_BASE_URL`** — the base URL of the Authorization server (OAuth)
51
-
-**`BACKEND_API_BASE`** — the base URL for backend REST API calls
52
-
-**`BACKEND_API_AUTH`** - the URL to get the OFBiz APIs access token
53
-
-**`BACKEND_AUTH_TOKEN`** — the token used to authorize backend API calls
54
63
-**`SERVER_PORT`** — the port on which the MCP server listens for client connections (required only for the remote server)
64
+
-**`MCP_SERVER_CORS_ORIGINS`** — CORS origin allowed
65
+
-**`AUTHZ_SERVER_BASE_URL`** — the base URL of the Authorization (Authz) server (OAuth)
66
+
-**`BACKEND_API_BASE`** — the base URL for backend REST API calls
67
+
-**`MCP_SERVER_CLIENT_ID`** — Client ID required for token exchange, as registered in Authz server
68
+
-**`MCP_SERVER_CLIENT_SECRET`** — the secret associated with **`MCP_SERVER_CLIENT_ID`**
69
+
-**`SCOPES_SUPPORTED`** — the scopes that the MCP client can request
70
+
-**`BACKEND_API_AUDIENCE`** — the OAuth audience paramenter for the backend system
71
+
-**`BACKEND_API_RESOURCE`** — the OAuth resource parameter for the backend system
72
+
-**`BACKEND_API_AUTH`** - the URL to get the OFBiz APIs access token used if token exchange is not enabled
73
+
-**`BACKEND_AUTH_TOKEN`** — the token to authorize backend API calls used if token exchange is not enabled
74
+
-**`RATE_LIMIT_WINDOW_MS`** — time window in ms for the requests rate limiting feature
75
+
-**`RATE_LIMIT_MAX_REQUESTS`** — max number of requests allowed in the time window
76
+
55
77
56
78
If either **`MCP_SERVER_BASE_URL`** or **`AUTHZ_SERVER_BASE_URL`** are not set, authorization is disabled and the MCP server is publicly accessible.
57
79
58
-
The authorization token for the OFBiz API can be easily generated and set up by running the script:
80
+
If authorization is enabled, but either **`MCP_SERVER_CLIENT_ID`** or **`MCP_SERVER_CLIENT_SECRET`** are not set, token exchange is disabled.
81
+
82
+
If token exchange is not enabled, the access token for the OFBiz API can be easily generated and set up by running the script:
59
83
60
84
`update_token.sh <user> <password>`
61
85
62
-
This script retrieves a JWT for an OOTB OFBiz instance (e.g., `https://demo-stable.ofbiz.apache.org/rest/auth/token`).
86
+
This script retrieves a JWT for an OOTB OFBiz instance, as specified by **`BACKEND_API_AUTH`** (e.g., `https://demo-stable.ofbiz.apache.org/rest/auth/token`).
63
87
64
88
---
65
89
66
90
## Project Structure
67
91
68
92
```text
69
-
mcp-prototypes/
93
+
mcp-server-for-apache-ofbiz/
70
94
├── config/
71
95
│ └── config.json # Server configuration (backend API base, auth token, etc.)
72
96
├── src/
73
-
│ ├── server-local.ts # Local MCP server (stdio transport)
97
+
│ ├── server-local.ts # Local MCP server (stdio transport)
74
98
│ ├── server-remote.ts # Remote MCP server (Streamable HTTP transport)
75
99
│ ├── toolLoader.ts # Loader of tool definitions from "tools/"
76
100
│ └── tools/
77
101
│ └── findProductById.ts # Example tool calling an Apache OFBiz REST endpoint
78
102
├── update_token.sh # Script to refresh backend auth token
79
103
├── package.json
80
104
├── tsconfig.json
81
-
└── README.md
105
+
└── README.md # This readme file
106
+
└── LICENSE # Apache License, Version 2.0
82
107
```
83
108
84
109
## Build the Project
@@ -90,7 +115,7 @@ npm run build
90
115
91
116
## Test the Local MCP Server
92
117
93
-
You can test the local MCP server with **Claude Desktop**.
118
+
You can test the local MCP server with the free version of **Claude Desktop**.
94
119
95
120
Edit or create the Claude Desktop configuration file:
96
121
@@ -103,7 +128,7 @@ Add your local MCP server configuration:
0 commit comments