@fractary/codex-mcp 0.1.0
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 +277 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +545 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +121 -0
- package/dist/index.js +444 -0
- package/dist/index.js.map +1 -0
- package/package.json +74 -0
package/README.md
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# @fractary/codex-mcp-server
|
|
2
|
+
|
|
3
|
+
MCP (Model Context Protocol) server for Fractary Codex knowledge management.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides a standalone MCP server that exposes Fractary Codex functionality as tools for AI agents and applications. It supports both stdio and HTTP/SSE transports for integration with Claude Code, LangChain, and other MCP-compatible clients.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
### Global Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g @fractary/codex-mcp-server
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Direct Usage (npx)
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx @fractary/codex-mcp-server
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### As Dependency
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @fractary/codex-mcp-server
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Claude Code Integration
|
|
32
|
+
|
|
33
|
+
Add to your `.claude/settings.json`:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"mcpServers": {
|
|
38
|
+
"fractary-codex": {
|
|
39
|
+
"command": "npx",
|
|
40
|
+
"args": ["-y", "@fractary/codex-mcp-server", "--config", ".fractary/codex.yaml"]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Stdio Mode (Default)
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
fractary-codex-mcp --config .fractary/codex.yaml
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The server communicates via stdin/stdout using the MCP protocol.
|
|
53
|
+
|
|
54
|
+
### HTTP Mode
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
fractary-codex-mcp --port 3000 --host localhost
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The server exposes an SSE (Server-Sent Events) endpoint for HTTP clients.
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
Create a `.fractary/codex.yaml` configuration file:
|
|
65
|
+
|
|
66
|
+
```yaml
|
|
67
|
+
cache:
|
|
68
|
+
dir: .codex-cache
|
|
69
|
+
maxMemorySize: 104857600 # 100 MB
|
|
70
|
+
defaultTtl: 3600 # 1 hour
|
|
71
|
+
|
|
72
|
+
storage:
|
|
73
|
+
providers:
|
|
74
|
+
- type: local
|
|
75
|
+
basePath: ./knowledge
|
|
76
|
+
- type: github
|
|
77
|
+
token: ${GITHUB_TOKEN}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Environment Variables
|
|
81
|
+
|
|
82
|
+
- `FRACTARY_CONFIG`: Path to configuration file (default: `.fractary/codex.yaml`)
|
|
83
|
+
- `GITHUB_TOKEN`: GitHub personal access token for GitHub storage provider
|
|
84
|
+
|
|
85
|
+
## Available Tools
|
|
86
|
+
|
|
87
|
+
The MCP server exposes the following tools:
|
|
88
|
+
|
|
89
|
+
### codex_fetch
|
|
90
|
+
|
|
91
|
+
Fetch a document from the Codex knowledge base by URI.
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"uri": "codex://org/project/path/to/file.md",
|
|
96
|
+
"branch": "main",
|
|
97
|
+
"noCache": false
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### codex_search
|
|
102
|
+
|
|
103
|
+
Search for documents in the knowledge base.
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"query": "authentication",
|
|
108
|
+
"org": "fractary",
|
|
109
|
+
"project": "codex",
|
|
110
|
+
"limit": 10,
|
|
111
|
+
"type": "docs"
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### codex_list
|
|
116
|
+
|
|
117
|
+
List cached documents.
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"org": "fractary",
|
|
122
|
+
"project": "codex",
|
|
123
|
+
"includeExpired": false
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### codex_invalidate
|
|
128
|
+
|
|
129
|
+
Invalidate cached documents by pattern.
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"pattern": "docs/**"
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Architecture
|
|
138
|
+
|
|
139
|
+
The MCP server bridges the Codex SDK with the MCP protocol:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
┌─────────────────────────────────────┐
|
|
143
|
+
│ MCP Client (Claude Code, etc.) │
|
|
144
|
+
└─────────────┬───────────────────────┘
|
|
145
|
+
│ JSON-RPC (stdio/HTTP)
|
|
146
|
+
▼
|
|
147
|
+
┌─────────────────────────────────────┐
|
|
148
|
+
│ @fractary/codex-mcp-server │
|
|
149
|
+
│ ┌───────────────────────────────┐ │
|
|
150
|
+
│ │ MCP Protocol Handler │ │
|
|
151
|
+
│ │ (StdioTransport / SSE) │ │
|
|
152
|
+
│ └─────────────┬─────────────────┘ │
|
|
153
|
+
│ │ │
|
|
154
|
+
│ ┌─────────────▼─────────────────┐ │
|
|
155
|
+
│ │ Tool Registration Bridge │ │
|
|
156
|
+
│ │ (registerCodexTools) │ │
|
|
157
|
+
│ └─────────────┬─────────────────┘ │
|
|
158
|
+
└────────────────┼─────────────────────┘
|
|
159
|
+
│
|
|
160
|
+
▼
|
|
161
|
+
┌─────────────────────────────────────┐
|
|
162
|
+
│ @fractary/codex (SDK) │
|
|
163
|
+
│ ┌─────────┐ ┌──────────────┐ │
|
|
164
|
+
│ │ Cache │ │ Storage │ │
|
|
165
|
+
│ │ Manager │ │ Manager │ │
|
|
166
|
+
│ └─────────┘ └──────────────┘ │
|
|
167
|
+
└─────────────────────────────────────┘
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Development
|
|
171
|
+
|
|
172
|
+
### Build
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
npm run build
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Watch Mode
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
npm run dev
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Type Check
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
npm run typecheck
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Testing
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
npm test
|
|
194
|
+
npm run test:watch
|
|
195
|
+
npm run test:coverage
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Linting
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
npm run lint
|
|
202
|
+
npm run format
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Programmatic Usage
|
|
206
|
+
|
|
207
|
+
You can also use the MCP server programmatically:
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js'
|
|
211
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
212
|
+
import { CacheManager, StorageManager } from '@fractary/codex'
|
|
213
|
+
import { registerCodexTools } from '@fractary/codex-mcp-server'
|
|
214
|
+
|
|
215
|
+
// Initialize SDK managers
|
|
216
|
+
const storage = StorageManager.create({ /* config */ })
|
|
217
|
+
const cache = CacheManager.create({ /* config */ })
|
|
218
|
+
cache.setStorageManager(storage)
|
|
219
|
+
|
|
220
|
+
// Create MCP server
|
|
221
|
+
const server = new Server(
|
|
222
|
+
{ name: 'fractary-codex', version: '0.1.0' },
|
|
223
|
+
{ capabilities: { tools: {}, resources: {} } }
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
// Register Codex tools
|
|
227
|
+
registerCodexTools(server, { cache, storage })
|
|
228
|
+
|
|
229
|
+
// Connect transport
|
|
230
|
+
const transport = new StdioServerTransport()
|
|
231
|
+
await server.connect(transport)
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Migration from SDK-Embedded MCP
|
|
235
|
+
|
|
236
|
+
If you were using the MCP server from `@fractary/codex` (versions ≤0.1.x), update your configuration:
|
|
237
|
+
|
|
238
|
+
**Before:**
|
|
239
|
+
```json
|
|
240
|
+
{
|
|
241
|
+
"mcpServers": {
|
|
242
|
+
"fractary-codex": {
|
|
243
|
+
"command": "npx",
|
|
244
|
+
"args": ["@fractary/codex", "mcp", "--config", ".fractary/codex.yaml"]
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
**After:**
|
|
251
|
+
```json
|
|
252
|
+
{
|
|
253
|
+
"mcpServers": {
|
|
254
|
+
"fractary-codex": {
|
|
255
|
+
"command": "npx",
|
|
256
|
+
"args": ["-y", "@fractary/codex-mcp-server", "--config", ".fractary/codex.yaml"]
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The functionality remains identical; only the package name has changed.
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
MIT
|
|
267
|
+
|
|
268
|
+
## Related Packages
|
|
269
|
+
|
|
270
|
+
- [@fractary/codex](https://www.npmjs.com/package/@fractary/codex) - Core SDK
|
|
271
|
+
- [@fractary/codex-cli](https://www.npmjs.com/package/@fractary/codex-cli) - CLI tool
|
|
272
|
+
|
|
273
|
+
## Links
|
|
274
|
+
|
|
275
|
+
- [GitHub Repository](https://github.com/fractary/codex)
|
|
276
|
+
- [Issue Tracker](https://github.com/fractary/codex/issues)
|
|
277
|
+
- [MCP Specification](https://modelcontextprotocol.io)
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|