Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit d922559

Browse files
feat: Add OFREP flag evaluation tool (#4)
* feat: Add OpenFeature Remote Evaluation Protocol tool Co-authored-by: jonathan <jonathan@taplytics.com> * fix: build of OFREP tool import and types * chore: extract OFREP API calling logic into separate function * chore: README.md updates * fix: update README config example and standardize registerOfrepTools API * feat: add vitest for OFREP tests * feat: add new vitest files * feat: add GH action to build / test * chore: cleanup * chore: update tests, fix error responses * test: mock fetch using Response in ofrepTools tests --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 504aa46 commit d922559

File tree

8 files changed

+2214
-4
lines changed

8 files changed

+2214
-4
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
build-and-test:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
node-version: [18.x, 20.x, 22.x]
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: "npm"
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Run build
30+
run: npm run build
31+
32+
- name: Run tests
33+
run: npm run test

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,41 @@ Fetches and returns OpenFeature SDK install prompt Markdown for a given technolo
131131
- react
132132
- ruby
133133

134+
### `ofrep_flag_eval`
135+
136+
Evaluate feature flags via OpenFeature Remote Evaluation Protocol (OFREP). If `flag_key` is omitted, performs bulk evaluation.
137+
138+
References: [`open-feature/protocol` repo](https://github.com/open-feature/protocol), [OFREP OpenAPI spec](https://raw.githubusercontent.com/open-feature/protocol/refs/heads/main/service/openapi.yaml)
139+
140+
Parameters (all optional unless noted):
141+
- `base_url` (string, optional): Base URL of your OFREP-compatible flag service. If omitted, the server uses env/config (see below).
142+
- `flag_key` (string, optional): If provided, calls single flag evaluation: `/ofrep/v1/evaluate/flags/{key}`. If omitted, calls bulk: `/ofrep/v1/evaluate/flags`.
143+
- `context` (object, optional): Evaluation context, e.g. `{ "targetingKey": "user-123", ... }`.
144+
- `etag` (string, optional): For bulk requests, sent as `If-None-Match` to enable 304 caching semantics.
145+
- `auth` (object, optional): Inline auth for this call only.
146+
- `bearer_token` (string, optional): Sets `Authorization: Bearer <token>`.
147+
- `api_key` (string, optional): Sets `X-API-Key: <key>`.
148+
149+
Auth and base URL resolution (priority):
150+
1. Tool call args: `base_url`, `auth.bearer_token`, `auth.api_key`
151+
2. Environment variables: `OPENFEATURE_OFREP_BASE_URL` (or `OFREP_BASE_URL`), `OPENFEATURE_OFREP_BEARER_TOKEN` (or `OFREP_BEARER_TOKEN`), `OPENFEATURE_OFREP_API_KEY` (or `OFREP_API_KEY`)
152+
3. Config file: `~/.openfeature-mcp.json` (override with `OPENFEATURE_MCP_CONFIG_PATH`)
153+
154+
Example `~/.openfeature-mcp.json`:
155+
```json
156+
{
157+
"OFREP": {
158+
"baseUrl": "https://flags.example.com",
159+
"bearerToken": "<token>",
160+
"apiKey": "<key>"
161+
}
162+
}
163+
```
164+
165+
Notes:
166+
- Bulk requests may return `ETag`. Pass it back via `etag` to leverage 304 Not Modified.
167+
- Either bearer token or API key can be supplied; both are supported by the spec.
168+
134169
## Development
135170

136171
### Prerequisites

0 commit comments

Comments
 (0)