Skip to content

Commit 6f7ce22

Browse files
feat(mcp-server): connector-driven architecture with Agent-in-the-Loop retrieval
- Add KnowledgeConnector interface with 5 implementations: github-public (default, no auth, live fetch from raw.githubusercontent.com), github-private (auto PR via GitHub REST API), local (filesystem), sql/nosql (planned stubs) - Rewrite index.ts: 6 tools (list_domains, find_relevant_cycles, get_cycle_detail, get_dimension_guidance, refresh_knowledge, contribute_cycle); no numeric scores exposed — agent reasons over ranked keyword-similarity candidates - 1-hour TTL cache with bundled knowledge as offline fallback - Transport connected before background preload to avoid missed stdin - Add KNOWLEDGE.md for agents using GitHub MCP path (self-documenting knowledge base) - Bump cli and mcp-server to 0.1.3 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a5870fd commit 6f7ce22

13 files changed

Lines changed: 753 additions & 562 deletions

File tree

KNOWLEDGE.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Fluently Knowledge Base
2+
3+
This document is a navigation guide for agents and humans interacting with the Fluently 4D knowledge base — either directly via GitHub MCP or through a configured Fluently MCP server.
4+
5+
## What is a 4D cycle?
6+
7+
A **Fluently 4D cycle** is a validated pattern for a specific AI-assisted workflow. It describes four dimensions of good human-AI collaboration:
8+
9+
| Dimension | Question it answers |
10+
|---|---|
11+
| **Delegation** | Who owns the decision — human, AI, or both? What level of autonomy is appropriate? |
12+
| **Description** | How should the task be framed so AI understands context fully? |
13+
| **Discernment** | How do you evaluate whether the AI output is trustworthy? When do you push back? |
14+
| **Diligence** | What human accountability is required after AI is involved? Who signs off? |
15+
16+
Each dimension includes:
17+
- `description` — what good looks like
18+
- `example` — a concrete, real-world instance
19+
- `antipattern` — what to avoid
20+
21+
## Knowledge base structure
22+
23+
```
24+
knowledge/
25+
├── index.json ← pre-built index of all cycles (fetch this first)
26+
├── coding-code-review-triage.yaml ← individual cycle files
27+
├── coding-test-case-generation.yaml
28+
├── writing-content-development.yaml
29+
└── ...
30+
```
31+
32+
File naming: `{domain}-{id}.yaml`
33+
34+
## index.json format
35+
36+
```json
37+
{
38+
"entries": [
39+
{
40+
"id": "code-review-triage",
41+
"title": "Code Review Triage",
42+
"domain": "coding",
43+
"tags": ["code-review", "triage", "automation"],
44+
"contributor": "Dakan & Feller",
45+
"version": "1.0.0",
46+
"summary": "...",
47+
"dimensions": {
48+
"delegation": { "description": "...", "example": "...", "antipattern": "..." },
49+
"description": { "description": "...", "example": "...", "antipattern": "..." },
50+
"discernment": { "description": "...", "example": "...", "antipattern": "..." },
51+
"diligence": { "description": "...", "example": "...", "antipattern": "..." }
52+
},
53+
"score_hints": { "delegation": 0.2, "description": 0.3, "discernment": 0.3, "diligence": 0.2 }
54+
}
55+
]
56+
}
57+
```
58+
59+
## Available domains
60+
61+
coding · writing · research · education · legal · healthcare · general
62+
63+
## How to find a relevant cycle (GitHub MCP path)
64+
65+
1. Fetch `knowledge/index.json` — this gives you all cycles in one read
66+
2. Reason over the entries to find the best match for the task at hand
67+
3. Fetch the specific YAML file for full dimension detail if needed
68+
69+
Raw URL (no auth required — public repo):
70+
```
71+
https://raw.githubusercontent.com/faical-yannick-congo/fluently/main/knowledge/index.json
72+
```
73+
74+
## How to contribute a new cycle (GitHub MCP path)
75+
76+
Contributions require a GitHub token. The cycle must:
77+
1. Follow the YAML schema (all 4 dimensions, each with description + example + antipattern)
78+
2. Have a unique `id` (kebab-case slug)
79+
3. Belong to one of the supported domains
80+
4. Include `score_hints` that sum to 1.0
81+
82+
Steps:
83+
1. Fork https://github.com/faical-yannick-congo/fluently
84+
2. Add your YAML to `knowledge/{domain}-{id}.yaml`
85+
3. Open a pull request — CI will validate the schema automatically
86+
87+
## How to use the Fluently MCP server instead
88+
89+
Install and run:
90+
```bash
91+
npm install -g fluently-mcp-server
92+
4d-mcp-server
93+
```
94+
95+
Configure in your MCP client:
96+
```json
97+
{
98+
"mcpServers": {
99+
"fluently": { "command": "4d-mcp-server" }
100+
}
101+
}
102+
```
103+
104+
Default connector: `github-public` (fetches live from this repo, no auth needed).
105+
For private knowledge, see `packages/mcp-server/README.md`.

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fluently-cli",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"main": "src/index.ts",
55
"bin": {
66
"fluent": "dist/index.js"

packages/mcp-server/README.md

Lines changed: 75 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,143 +1,125 @@
1-
# @fluently/mcp-server
1+
# fluently-mcp-server
22

3-
MCP (Model Context Protocol) server for the Fluently AI Fluency 4D Framework. Exposes tools for scoring human-AI collaboration quality across the four dimensions: Delegation, Description, Discernment, and Diligence.
3+
MCP server for the Fluently 4D Framework. Exposes knowledge retrieval and contribution tools so AI agents can find, reason over, and extend Fluently 4D cycles.
44

5-
## Installation
6-
7-
Install as a workspace dependency:
8-
9-
```bash
10-
npm install
11-
```
12-
13-
## Building
14-
15-
```bash
16-
npm run build
17-
# or in watch mode
18-
npm run dev
19-
```
20-
21-
## Running the Server
22-
23-
### Stdio Transport (Local Use)
24-
25-
The server runs on stdio by default, suitable for local IDE/editor integration:
5+
## Install
266

277
```bash
28-
npm start
29-
# or directly
30-
node dist/bin.js
8+
npm install -g fluently-mcp-server
9+
4d-mcp-server
3110
```
3211

33-
The server will write logs to stderr and protocol messages to stdout.
12+
## Wire to Claude Desktop
3413

35-
### HTTP Transport (Optional Deployment)
14+
`~/Library/Application Support/Claude/claude_desktop_config.json` (Mac) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
3615

37-
To run the server over HTTP (for remote use, though not yet enabled by default), you would modify `src/index.ts` to use `HTTPServerTransport` instead:
38-
39-
```typescript
40-
import { HTTPServerTransport } from "@modelcontextprotocol/sdk/server/http.js";
41-
42-
const transport = new HTTPServerTransport({
43-
host: "localhost",
44-
port: 3000,
45-
});
16+
```json
17+
{
18+
"mcpServers": {
19+
"fluently": { "command": "4d-mcp-server" }
20+
}
21+
}
4622
```
4723

48-
Then rebuild and run.
24+
## Wire to Claude Code
4925

50-
## Configuration
51-
52-
### .mcp.json
53-
54-
The root `.mcp.json` file enables this server in compatible MCP clients:
26+
In your `settings.json`:
5527

5628
```json
5729
{
5830
"mcpServers": {
59-
"fluently": {
60-
"command": "node",
61-
"args": ["./packages/mcp-server/dist/bin.js"]
62-
}
31+
"fluently": { "command": "4d-mcp-server" }
6332
}
6433
}
6534
```
6635

6736
## Tools
6837

69-
### 1. compare_problem_space
70-
71-
Finds the top 3 similar past 4D plays from the knowledge base.
38+
| Tool | Purpose |
39+
|---|---|
40+
| `list_domains` | List available domains and cycle counts |
41+
| `find_relevant_cycles` | Retrieve ranked candidate cycles for a task (no scores — agent reasons) |
42+
| `get_cycle_detail` | Full 4D cycle by ID |
43+
| `get_dimension_guidance` | Antipatterns + examples for a dimension across all cycles |
44+
| `refresh_knowledge` | Re-fetch from the connector without restarting |
45+
| `contribute_cycle` | Validate and submit a new cycle to the knowledge source |
7246

73-
**Inputs:**
74-
- `task_description` (string, required): Description of the problem or task
75-
- `domain` (string, optional): Filter by domain (coding, writing, research, etc.)
47+
## Connectors
7648

77-
**Output:** Array of similar knowledge entries with similarity scores
49+
The server fetches knowledge from a configured source. Set `FLUENTLY_CONNECTOR` to choose.
7850

79-
### 2. score_delegation
51+
### github-public (default)
8052

81-
Scores the Delegation and Description dimensions with improvement advice.
53+
Fetches live from the public Fluently community repo. No auth required. Points to `faical-yannick-congo/fluently` by default.
8254

83-
**Inputs:**
84-
- `task` (string, required): The task to evaluate
85-
- `delegation_intent` (string, required): How you intend to delegate (automated, augmented, agentic)
55+
```bash
56+
# Default — no config needed
57+
4d-mcp-server
8658

87-
**Output:** Delegation + Description scores with specific improvement recommendations
59+
# Point to a public fork
60+
FLUENTLY_CONNECTOR=github-public \
61+
FLUENTLY_GITHUB_REPO=your-org/your-public-fork \
62+
4d-mcp-server
63+
```
8864

89-
### 3. evaluate_discernment
65+
Contributing requires opening a PR manually (YAML + instructions returned by `contribute_cycle`).
9066

91-
Evaluates discernment for an AI output: hallucination risk, confidence calibration, and human review requirements.
67+
### github-private
9268

93-
**Inputs:**
94-
- `ai_output` (string, required): The AI-generated output to evaluate
95-
- `original_task` (string, required): The original task given to the AI
69+
Fetches from a private GitHub repo via the GitHub API. Requires a personal access token with `repo` scope. `contribute_cycle` creates branches and PRs automatically.
9670

97-
**Output:** Discernment score, hallucination risk percentage, confidence calibration, and human review guidance
71+
```bash
72+
FLUENTLY_CONNECTOR=github-private \
73+
FLUENTLY_GITHUB_REPO=your-org/your-private-knowledge \
74+
FLUENTLY_GITHUB_TOKEN=ghp_xxx \
75+
4d-mcp-server
76+
```
9877

99-
### 4. check_diligence
78+
### local
10079

101-
Returns a diligence checklist: transparency requirements, accountability steps, and disclosure needs.
80+
Reads from a local directory. Ideal for development, air-gapped environments, or building private cycles before committing.
10281

103-
**Inputs:**
104-
- `task` (string, required): The task to evaluate
105-
- `domain` (string, required): The domain context
82+
```bash
83+
FLUENTLY_CONNECTOR=local \
84+
FLUENTLY_LOCAL_PATH=/path/to/your/knowledge \
85+
4d-mcp-server
86+
```
10687

107-
**Output:** Structured checklist for maintaining accountability and transparency
88+
`contribute_cycle` writes YAML files directly to the configured directory.
10889

109-
### 5. get_4d_score
90+
### sql _(planned)_
11091

111-
Master tool returning a complete 4D Score (0-100 per dimension plus overall) with one-sentence improvement tips.
92+
Reads cycles from a SQL database (PostgreSQL, SQLite). Coming in a future release.
11293

113-
**Inputs:**
114-
- `description` (string, required): Task description
115-
- `delegation` (string, required): How the task is being delegated
116-
- `output` (string, optional): AI output to evaluate for discernment
94+
### nosql _(planned)_
11795

118-
**Output:** Complete 4D profile with scores and improvement guidance
96+
Reads cycles from a NoSQL database (MongoDB). Coming in a future release.
11997

120-
## Knowledge Base
98+
## Environment variables
12199

122-
The server loads knowledge entries from the `knowledge/` directory at the workspace root. Knowledge files are YAML and must follow the schema defined in `@fluently/scorer`.
100+
| Variable | Default | Description |
101+
|---|---|---|
102+
| `FLUENTLY_CONNECTOR` | `github-public` | Which connector to use |
103+
| `FLUENTLY_GITHUB_REPO` | `faical-yannick-congo/fluently` | GitHub repo (`owner/repo`) |
104+
| `FLUENTLY_GITHUB_BRANCH` | `main` | Branch to read from |
105+
| `FLUENTLY_GITHUB_TOKEN` | _(none)_ | GitHub token — required for private repos and automated PRs |
106+
| `FLUENTLY_LOCAL_PATH` | `./knowledge` | Local knowledge directory (local connector only) |
123107

124-
Each entry defines best practices and antipatterns for all four dimensions across different domains.
108+
## Why no scoring?
125109

126-
## Architecture
110+
Numeric scores (delegation: 34/100) are biased by writing style and user maturity. Two people describing the same workflow in different vocabulary get different scores.
127111

128-
- **Transport**: Stdio (primary) for local editor integration
129-
- **Schema Validation**: via Zod in `@fluently/scorer`
130-
- **Similarity Matching**: cosine similarity on keyword sets
131-
- **Knowledge Loading**: dynamic from `knowledge/` directory at startup
112+
This server does **retrieval** — it finds the most relevant cycles using keyword similarity and returns them for you to reason over. You assess fit in context. That's more accurate and adapts to the specifics of the situation rather than returning a false-precision number.
132113

133-
## Development
114+
## Using GitHub MCP instead (community knowledge)
134115

135-
To add new tools, edit `src/index.ts` and:
116+
If you prefer to skip the custom server and work directly with the public knowledge base via GitHub MCP, read `KNOWLEDGE.md` at the repo root. The raw `index.json` is fetchable without auth and contains all cycles.
136117

137-
1. Define the Tool schema in a `*ToolDef` constant
138-
2. Register it in the `tools/list` handler
139-
3. Add the handler logic in the `tools/call` switch statement
140-
4. Rebuild and test
118+
The custom MCP server is the right choice when:
119+
- You need private knowledge that stays in your org
120+
- You want isolation from the community repo
121+
- You want structured tools (domain listing, dimension guidance, contribute flow)
122+
- You need the server to handle sync and refresh automatically
141123

142124
## License
143125

packages/mcp-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fluently-mcp-server",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "AI Fluency 4D Framework MCP server for scoring human-AI collaboration quality",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

packages/mcp-server/src/bin.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env node
2-
31
import { start } from "./index.js";
42

53
start().catch((error) => {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { KnowledgeConnector } from './types.js';
2+
import { GitHubPublicConnector } from './github-public.js';
3+
import { GitHubPrivateConnector } from './github-private.js';
4+
import { LocalConnector } from './local.js';
5+
import { SqlConnector } from './sql.js';
6+
import { NoSqlConnector } from './nosql.js';
7+
8+
export function createConnector(): KnowledgeConnector {
9+
const type = (process.env.FLUENTLY_CONNECTOR ?? 'github-public').toLowerCase();
10+
switch (type) {
11+
case 'github-public': return new GitHubPublicConnector();
12+
case 'github-private': return new GitHubPrivateConnector();
13+
case 'local': return new LocalConnector();
14+
case 'sql': return new SqlConnector();
15+
case 'nosql': return new NoSqlConnector();
16+
default:
17+
throw new Error(
18+
`Unknown connector "${type}". ` +
19+
`Valid values: github-public (default), github-private, local, sql, nosql`
20+
);
21+
}
22+
}

0 commit comments

Comments
 (0)