@fractary/core-mcp 0.1.1
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/LICENSE +21 -0
- package/README.md +272 -0
- package/dist/config.d.ts +40 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +112 -0
- package/dist/config.js.map +1 -0
- package/dist/handlers/docs.d.ts +58 -0
- package/dist/handlers/docs.d.ts.map +1 -0
- package/dist/handlers/docs.js +144 -0
- package/dist/handlers/docs.js.map +1 -0
- package/dist/handlers/file.d.ts +55 -0
- package/dist/handlers/file.d.ts.map +1 -0
- package/dist/handlers/file.js +153 -0
- package/dist/handlers/file.js.map +1 -0
- package/dist/handlers/helpers.d.ts +62 -0
- package/dist/handlers/helpers.d.ts.map +1 -0
- package/dist/handlers/helpers.js +100 -0
- package/dist/handlers/helpers.js.map +1 -0
- package/dist/handlers/index.d.ts +10 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +184 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/logs.d.ts +48 -0
- package/dist/handlers/logs.d.ts.map +1 -0
- package/dist/handlers/logs.js +99 -0
- package/dist/handlers/logs.js.map +1 -0
- package/dist/handlers/repo.d.ts +158 -0
- package/dist/handlers/repo.d.ts.map +1 -0
- package/dist/handlers/repo.js +651 -0
- package/dist/handlers/repo.js.map +1 -0
- package/dist/handlers/security.d.ts +38 -0
- package/dist/handlers/security.d.ts.map +1 -0
- package/dist/handlers/security.js +79 -0
- package/dist/handlers/security.js.map +1 -0
- package/dist/handlers/spec.d.ts +39 -0
- package/dist/handlers/spec.d.ts.map +1 -0
- package/dist/handlers/spec.js +99 -0
- package/dist/handlers/spec.js.map +1 -0
- package/dist/handlers/work.d.ts +147 -0
- package/dist/handlers/work.d.ts.map +1 -0
- package/dist/handlers/work.js +373 -0
- package/dist/handlers/work.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +42 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/docs.d.ts +7 -0
- package/dist/tools/docs.d.ts.map +1 -0
- package/dist/tools/docs.js +160 -0
- package/dist/tools/docs.js.map +1 -0
- package/dist/tools/file.d.ts +7 -0
- package/dist/tools/file.d.ts.map +1 -0
- package/dist/tools/file.js +144 -0
- package/dist/tools/file.js.map +1 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +18 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/logs.d.ts +7 -0
- package/dist/tools/logs.d.ts.map +1 -0
- package/dist/tools/logs.js +139 -0
- package/dist/tools/logs.js.map +1 -0
- package/dist/tools/repo.d.ts +7 -0
- package/dist/tools/repo.d.ts.map +1 -0
- package/dist/tools/repo.js +694 -0
- package/dist/tools/repo.js.map +1 -0
- package/dist/tools/spec.d.ts +7 -0
- package/dist/tools/spec.d.ts.map +1 -0
- package/dist/tools/spec.js +102 -0
- package/dist/tools/spec.js.map +1 -0
- package/dist/tools/work.d.ts +7 -0
- package/dist/tools/work.d.ts.map +1 -0
- package/dist/tools/work.js +384 -0
- package/dist/tools/work.js.map +1 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Fractary
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# @fractary/core-mcp
|
|
2
|
+
|
|
3
|
+
MCP (Model Context Protocol) server for Fractary Core SDK - provides universal tool access for work tracking, repository management, specifications, logs, file storage, and documentation across any MCP-compatible client.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **81 MCP Tools** across 6 modules:
|
|
8
|
+
- Work Tracking (19 tools): Issues, comments, labels, milestones
|
|
9
|
+
- Repository Management (38 tools): Git operations, PRs, branches, tags, worktrees
|
|
10
|
+
- Specifications (5 tools): Create, validate, refine specs
|
|
11
|
+
- Logging (5 tools): Capture, search, archive logs
|
|
12
|
+
- File Storage (7 tools): Read, write, copy, move files
|
|
13
|
+
- Documentation (7 tools): Create, search, export docs
|
|
14
|
+
|
|
15
|
+
- **5.3x Performance**: Direct SDK integration eliminates CLI subprocess overhead
|
|
16
|
+
- **Universal Compatibility**: Works with Claude Code, LangChain, n8n, and any MCP client
|
|
17
|
+
- **Multi-Platform Support**: GitHub, GitLab, Bitbucket, Jira, Linear
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install -g @fractary/core-mcp
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Configuration
|
|
26
|
+
|
|
27
|
+
### Claude Code Integration
|
|
28
|
+
|
|
29
|
+
Add to your `.claude/settings.json`:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"mcpServers": {
|
|
34
|
+
"fractary-core": {
|
|
35
|
+
"command": "npx",
|
|
36
|
+
"args": ["-y", "@fractary/core-mcp"],
|
|
37
|
+
"env": {
|
|
38
|
+
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Environment Variables
|
|
46
|
+
|
|
47
|
+
| Variable | Description | Required For |
|
|
48
|
+
|----------|-------------|--------------|
|
|
49
|
+
| `GITHUB_TOKEN` | GitHub personal access token | GitHub operations |
|
|
50
|
+
| `JIRA_TOKEN` | Jira API token | Jira operations |
|
|
51
|
+
| `JIRA_BASE_URL` | Jira instance URL | Jira operations |
|
|
52
|
+
| `JIRA_PROJECT` | Default Jira project key | Jira operations |
|
|
53
|
+
| `LINEAR_API_KEY` | Linear API key | Linear operations |
|
|
54
|
+
| `GITLAB_TOKEN` | GitLab personal access token | GitLab operations |
|
|
55
|
+
| `BITBUCKET_TOKEN` | Bitbucket app password | Bitbucket operations |
|
|
56
|
+
|
|
57
|
+
### Configuration File
|
|
58
|
+
|
|
59
|
+
Alternatively, create `.fractary/config.json`:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"work": {
|
|
64
|
+
"platform": "github",
|
|
65
|
+
"owner": "your-org",
|
|
66
|
+
"repo": "your-repo",
|
|
67
|
+
"token": "ghp_..."
|
|
68
|
+
},
|
|
69
|
+
"repo": {
|
|
70
|
+
"platform": "github",
|
|
71
|
+
"owner": "your-org",
|
|
72
|
+
"repo": "your-repo",
|
|
73
|
+
"token": "ghp_..."
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Available Tools
|
|
79
|
+
|
|
80
|
+
### Work Module (19 tools)
|
|
81
|
+
|
|
82
|
+
- `fractary_work_issue_fetch` - Fetch issue details
|
|
83
|
+
- `fractary_work_issue_create` - Create new issue
|
|
84
|
+
- `fractary_work_issue_update` - Update issue
|
|
85
|
+
- `fractary_work_issue_assign` - Assign issue to user
|
|
86
|
+
- `fractary_work_issue_unassign` - Remove assignee
|
|
87
|
+
- `fractary_work_issue_close` - Close issue
|
|
88
|
+
- `fractary_work_issue_reopen` - Reopen issue
|
|
89
|
+
- `fractary_work_issue_search` - Search issues
|
|
90
|
+
- `fractary_work_issue_classify` - Classify work type
|
|
91
|
+
- `fractary_work_comment_create` - Add comment
|
|
92
|
+
- `fractary_work_comment_list` - List comments
|
|
93
|
+
- `fractary_work_label_add` - Add labels
|
|
94
|
+
- `fractary_work_label_remove` - Remove labels
|
|
95
|
+
- `fractary_work_label_set` - Set labels (replace all)
|
|
96
|
+
- `fractary_work_label_list` - List labels
|
|
97
|
+
- `fractary_work_milestone_create` - Create milestone
|
|
98
|
+
- `fractary_work_milestone_list` - List milestones
|
|
99
|
+
- `fractary_work_milestone_set` - Set milestone on issue
|
|
100
|
+
- `fractary_work_milestone_remove` - Remove milestone
|
|
101
|
+
|
|
102
|
+
### Repository Module (38 tools)
|
|
103
|
+
|
|
104
|
+
- `fractary_repo_status` - Get repository status
|
|
105
|
+
- `fractary_repo_branch_current` - Get current branch
|
|
106
|
+
- `fractary_repo_branch_create` - Create branch
|
|
107
|
+
- `fractary_repo_branch_delete` - Delete branch
|
|
108
|
+
- `fractary_repo_branch_list` - List branches
|
|
109
|
+
- `fractary_repo_branch_get` - Get branch details
|
|
110
|
+
- `fractary_repo_checkout` - Checkout branch
|
|
111
|
+
- `fractary_repo_is_dirty` - Check for uncommitted changes
|
|
112
|
+
- `fractary_repo_diff` - Get diff
|
|
113
|
+
- `fractary_repo_stage` - Stage files
|
|
114
|
+
- `fractary_repo_stage_all` - Stage all changes
|
|
115
|
+
- `fractary_repo_unstage` - Unstage files
|
|
116
|
+
- `fractary_repo_commit` - Create commit
|
|
117
|
+
- `fractary_repo_commit_get` - Get commit details
|
|
118
|
+
- `fractary_repo_commit_list` - List commits
|
|
119
|
+
- `fractary_repo_push` - Push to remote
|
|
120
|
+
- `fractary_repo_pull` - Pull from remote
|
|
121
|
+
- `fractary_repo_fetch` - Fetch from remote
|
|
122
|
+
- `fractary_repo_pr_create` - Create pull request
|
|
123
|
+
- `fractary_repo_pr_get` - Get PR details
|
|
124
|
+
- `fractary_repo_pr_update` - Update PR
|
|
125
|
+
- `fractary_repo_pr_comment` - Comment on PR
|
|
126
|
+
- `fractary_repo_pr_review` - Review PR
|
|
127
|
+
- `fractary_repo_pr_request_review` - Request reviewers
|
|
128
|
+
- `fractary_repo_pr_approve` - Approve PR
|
|
129
|
+
- `fractary_repo_pr_merge` - Merge PR
|
|
130
|
+
- `fractary_repo_pr_list` - List PRs
|
|
131
|
+
- `fractary_repo_tag_create` - Create tag
|
|
132
|
+
- `fractary_repo_tag_delete` - Delete tag
|
|
133
|
+
- `fractary_repo_tag_push` - Push tag
|
|
134
|
+
- `fractary_repo_tag_list` - List tags
|
|
135
|
+
- `fractary_repo_worktree_create` - Create worktree
|
|
136
|
+
- `fractary_repo_worktree_list` - List worktrees
|
|
137
|
+
- `fractary_repo_worktree_remove` - Remove worktree
|
|
138
|
+
- `fractary_repo_worktree_prune` - Prune stale worktrees
|
|
139
|
+
- `fractary_repo_worktree_cleanup` - Cleanup worktrees
|
|
140
|
+
- `fractary_repo_branch_name_generate` - Generate semantic branch name
|
|
141
|
+
|
|
142
|
+
### Spec Module (5 tools)
|
|
143
|
+
|
|
144
|
+
- `fractary_spec_create` - Create specification
|
|
145
|
+
- `fractary_spec_validate` - Validate spec
|
|
146
|
+
- `fractary_spec_refine` - Refine spec
|
|
147
|
+
- `fractary_spec_list` - List specs
|
|
148
|
+
- `fractary_spec_read` - Read spec content
|
|
149
|
+
|
|
150
|
+
### Logs Module (5 tools)
|
|
151
|
+
|
|
152
|
+
- `fractary_logs_capture` - Capture log entry
|
|
153
|
+
- `fractary_logs_search` - Search logs
|
|
154
|
+
- `fractary_logs_archive` - Archive logs
|
|
155
|
+
- `fractary_logs_list` - List log entries
|
|
156
|
+
- `fractary_logs_read` - Read log entry
|
|
157
|
+
|
|
158
|
+
### File Module (7 tools)
|
|
159
|
+
|
|
160
|
+
- `fractary_file_read` - Read file
|
|
161
|
+
- `fractary_file_write` - Write file
|
|
162
|
+
- `fractary_file_list` - List files
|
|
163
|
+
- `fractary_file_delete` - Delete file
|
|
164
|
+
- `fractary_file_exists` - Check file exists
|
|
165
|
+
- `fractary_file_copy` - Copy file
|
|
166
|
+
- `fractary_file_move` - Move file
|
|
167
|
+
|
|
168
|
+
### Docs Module (7 tools)
|
|
169
|
+
|
|
170
|
+
- `fractary_docs_create` - Create documentation
|
|
171
|
+
- `fractary_docs_update` - Update documentation
|
|
172
|
+
- `fractary_docs_search` - Search docs
|
|
173
|
+
- `fractary_docs_export` - Export docs
|
|
174
|
+
- `fractary_docs_list` - List docs
|
|
175
|
+
- `fractary_docs_read` - Read doc content
|
|
176
|
+
- `fractary_docs_delete` - Delete documentation
|
|
177
|
+
|
|
178
|
+
## Usage Example
|
|
179
|
+
|
|
180
|
+
### With Claude Code
|
|
181
|
+
|
|
182
|
+
```javascript
|
|
183
|
+
// Tools are automatically available in Claude Code
|
|
184
|
+
// Example: Fetch an issue
|
|
185
|
+
Tool: fractary_work_issue_fetch
|
|
186
|
+
Parameters: { "issue_number": "123" }
|
|
187
|
+
|
|
188
|
+
// Create a branch
|
|
189
|
+
Tool: fractary_repo_branch_create
|
|
190
|
+
Parameters: { "name": "feature/new-feature" }
|
|
191
|
+
|
|
192
|
+
// Create a pull request
|
|
193
|
+
Tool: fractary_repo_pr_create
|
|
194
|
+
Parameters: {
|
|
195
|
+
"title": "Add new feature",
|
|
196
|
+
"body": "Description of changes"
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Programmatic Use
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
204
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
205
|
+
import { registerAllTools, registerAllHandlers } from '@fractary/core-mcp';
|
|
206
|
+
import { loadConfig } from '@fractary/core-mcp';
|
|
207
|
+
|
|
208
|
+
const config = await loadConfig();
|
|
209
|
+
const server = new Server(
|
|
210
|
+
{ name: 'fractary-core', version: '0.1.0' },
|
|
211
|
+
{ capabilities: { tools: {} } }
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
registerAllTools(server);
|
|
215
|
+
registerAllHandlers(server, config);
|
|
216
|
+
|
|
217
|
+
const transport = new StdioServerTransport();
|
|
218
|
+
await server.connect(transport);
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Performance
|
|
222
|
+
|
|
223
|
+
| Operation | CLI Time | MCP Time | Speedup |
|
|
224
|
+
|-----------|----------|----------|---------|
|
|
225
|
+
| Single issue fetch | 800ms | 150ms | 5.3x |
|
|
226
|
+
| 10 operations | 8000ms | 1500ms | 5.3x |
|
|
227
|
+
| Branch + commit + PR | 2400ms | 450ms | 5.3x |
|
|
228
|
+
|
|
229
|
+
## Development
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
# Install dependencies
|
|
233
|
+
npm install
|
|
234
|
+
|
|
235
|
+
# Build
|
|
236
|
+
npm run build
|
|
237
|
+
|
|
238
|
+
# Run tests
|
|
239
|
+
npm test
|
|
240
|
+
|
|
241
|
+
# Watch mode
|
|
242
|
+
npm run dev
|
|
243
|
+
|
|
244
|
+
# Lint
|
|
245
|
+
npm run lint
|
|
246
|
+
|
|
247
|
+
# Type check
|
|
248
|
+
npm run typecheck
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## License
|
|
252
|
+
|
|
253
|
+
MIT
|
|
254
|
+
|
|
255
|
+
## Documentation
|
|
256
|
+
|
|
257
|
+
- **[MCP Server Documentation](../../../README.md#mcp-server)** - Server setup and integration
|
|
258
|
+
- **[Configuration Guide](../../../docs/guides/configuration.md)** - Configuration options
|
|
259
|
+
- **[Integration Guide](../../../docs/guides/integration.md)** - Integration patterns
|
|
260
|
+
- **[API Reference](../../../docs/guides/api-reference.md)** - Complete tool reference
|
|
261
|
+
|
|
262
|
+
## Related Packages
|
|
263
|
+
|
|
264
|
+
- **[@fractary/core](../../sdk/js/)** - Core SDK for JavaScript/TypeScript
|
|
265
|
+
- **[@fractary/core-cli](../../cli/)** - Command-line interface
|
|
266
|
+
|
|
267
|
+
## Links
|
|
268
|
+
|
|
269
|
+
- [GitHub Repository](https://github.com/fractary/core)
|
|
270
|
+
- [Issue Tracker](https://github.com/fractary/core/issues)
|
|
271
|
+
- [NPM Package](https://www.npmjs.com/package/@fractary/core-mcp)
|
|
272
|
+
- [MCP Protocol Specification](https://spec.modelcontextprotocol.io/)
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration interface for the MCP server
|
|
3
|
+
*/
|
|
4
|
+
export interface Config {
|
|
5
|
+
work?: {
|
|
6
|
+
platform: 'github' | 'jira' | 'linear';
|
|
7
|
+
owner?: string;
|
|
8
|
+
repo?: string;
|
|
9
|
+
token?: string;
|
|
10
|
+
project?: string;
|
|
11
|
+
};
|
|
12
|
+
repo?: {
|
|
13
|
+
platform: 'github' | 'gitlab' | 'bitbucket';
|
|
14
|
+
owner?: string;
|
|
15
|
+
repo?: string;
|
|
16
|
+
token?: string;
|
|
17
|
+
defaultBranch?: string;
|
|
18
|
+
};
|
|
19
|
+
spec?: {
|
|
20
|
+
localPath?: string;
|
|
21
|
+
};
|
|
22
|
+
logs?: {
|
|
23
|
+
localPath?: string;
|
|
24
|
+
};
|
|
25
|
+
file?: {
|
|
26
|
+
basePath?: string;
|
|
27
|
+
};
|
|
28
|
+
docs?: {
|
|
29
|
+
docsDir?: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Load configuration from environment variables and config files
|
|
34
|
+
* Priority:
|
|
35
|
+
* 1. Environment variables
|
|
36
|
+
* 2. Project config: {cwd}/.fractary/config.json
|
|
37
|
+
* 3. User config: ~/.fractary/config.json
|
|
38
|
+
*/
|
|
39
|
+
export declare function loadConfig(): Promise<Config>;
|
|
40
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,EAAE;QACL,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;QACvC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,IAAI,CAAC,EAAE;QACL,QAAQ,EAAE,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;QAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,IAAI,CAAC,EAAE;QACL,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,IAAI,CAAC,EAAE;QACL,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,IAAI,CAAC,EAAE;QACL,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CA8GlD"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { access, readFile } from 'fs/promises';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
import { constants } from 'fs';
|
|
5
|
+
import { sanitizeSecrets } from './handlers/security.js';
|
|
6
|
+
/**
|
|
7
|
+
* Load configuration from environment variables and config files
|
|
8
|
+
* Priority:
|
|
9
|
+
* 1. Environment variables
|
|
10
|
+
* 2. Project config: {cwd}/.fractary/config.json
|
|
11
|
+
* 3. User config: ~/.fractary/config.json
|
|
12
|
+
*/
|
|
13
|
+
export async function loadConfig() {
|
|
14
|
+
const config = {};
|
|
15
|
+
// 1. Load from environment variables
|
|
16
|
+
// Priority order: GITHUB > JIRA > LINEAR for work, GITHUB > GITLAB > BITBUCKET for repo
|
|
17
|
+
// Only set if not already configured (respects priority)
|
|
18
|
+
// Work configuration (GitHub takes priority)
|
|
19
|
+
if (process.env.GITHUB_TOKEN && !config.work) {
|
|
20
|
+
config.work = {
|
|
21
|
+
platform: 'github',
|
|
22
|
+
owner: process.env.GITHUB_OWNER,
|
|
23
|
+
repo: process.env.GITHUB_REPO,
|
|
24
|
+
token: process.env.GITHUB_TOKEN,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (process.env.JIRA_TOKEN && !config.work) {
|
|
28
|
+
config.work = {
|
|
29
|
+
platform: 'jira',
|
|
30
|
+
token: process.env.JIRA_TOKEN,
|
|
31
|
+
project: process.env.JIRA_PROJECT,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (process.env.LINEAR_API_KEY && !config.work) {
|
|
35
|
+
config.work = {
|
|
36
|
+
platform: 'linear',
|
|
37
|
+
token: process.env.LINEAR_API_KEY,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Repo configuration (GitHub takes priority)
|
|
41
|
+
if (process.env.GITHUB_TOKEN && !config.repo) {
|
|
42
|
+
config.repo = {
|
|
43
|
+
platform: 'github',
|
|
44
|
+
owner: process.env.GITHUB_OWNER,
|
|
45
|
+
repo: process.env.GITHUB_REPO,
|
|
46
|
+
token: process.env.GITHUB_TOKEN,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (process.env.GITLAB_TOKEN && !config.repo) {
|
|
50
|
+
config.repo = {
|
|
51
|
+
platform: 'gitlab',
|
|
52
|
+
owner: process.env.GITLAB_OWNER,
|
|
53
|
+
repo: process.env.GITLAB_REPO,
|
|
54
|
+
token: process.env.GITLAB_TOKEN,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (process.env.BITBUCKET_TOKEN && !config.repo) {
|
|
58
|
+
config.repo = {
|
|
59
|
+
platform: 'bitbucket',
|
|
60
|
+
owner: process.env.BITBUCKET_OWNER,
|
|
61
|
+
repo: process.env.BITBUCKET_REPO,
|
|
62
|
+
token: process.env.BITBUCKET_TOKEN,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// 2. Load from config files (project first, then user)
|
|
66
|
+
const configPaths = [
|
|
67
|
+
join(process.cwd(), '.fractary', 'config.json'),
|
|
68
|
+
join(homedir(), '.fractary', 'config.json'),
|
|
69
|
+
];
|
|
70
|
+
for (const configPath of configPaths) {
|
|
71
|
+
try {
|
|
72
|
+
// Check if file exists using async access
|
|
73
|
+
await access(configPath, constants.F_OK);
|
|
74
|
+
// Read file asynchronously
|
|
75
|
+
const fileContent = await readFile(configPath, 'utf-8');
|
|
76
|
+
const fileConfig = JSON.parse(fileContent);
|
|
77
|
+
// Merge file config with existing config (env vars take precedence)
|
|
78
|
+
if (fileConfig.work && !config.work) {
|
|
79
|
+
config.work = fileConfig.work;
|
|
80
|
+
}
|
|
81
|
+
if (fileConfig.repo && !config.repo) {
|
|
82
|
+
config.repo = fileConfig.repo;
|
|
83
|
+
}
|
|
84
|
+
if (fileConfig.spec) {
|
|
85
|
+
config.spec = { ...fileConfig.spec, ...config.spec };
|
|
86
|
+
}
|
|
87
|
+
if (fileConfig.logs) {
|
|
88
|
+
config.logs = { ...fileConfig.logs, ...config.logs };
|
|
89
|
+
}
|
|
90
|
+
if (fileConfig.file) {
|
|
91
|
+
config.file = { ...fileConfig.file, ...config.file };
|
|
92
|
+
}
|
|
93
|
+
if (fileConfig.docs) {
|
|
94
|
+
config.docs = { ...fileConfig.docs, ...config.docs };
|
|
95
|
+
}
|
|
96
|
+
// Use first config file found
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
// File doesn't exist or read error - skip to next path
|
|
101
|
+
if (error instanceof Error && 'code' in error && error.code !== 'ENOENT') {
|
|
102
|
+
// Sanitize error message to prevent token/secret exposure (only for non-ENOENT errors)
|
|
103
|
+
// Uses comprehensive secret detection to catch tokens, API keys, bearer auth, etc.
|
|
104
|
+
const sanitizedError = sanitizeSecrets(error.message);
|
|
105
|
+
const sanitizedPath = sanitizeSecrets(configPath);
|
|
106
|
+
console.error(`Failed to load config from ${sanitizedPath}:`, sanitizedError);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return config;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AA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C,KAAK,CAAC,8BAA8B,aAAa,GAAG,EAAE,cAAc,CAAC,CAAC;YAChF,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { Config } from '../config.js';
|
|
3
|
+
/**
|
|
4
|
+
* Handler for fractary_docs_create
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleDocsCreate(params: {
|
|
7
|
+
id: string;
|
|
8
|
+
title: string;
|
|
9
|
+
content: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
tags?: string[];
|
|
12
|
+
}, config: Config): Promise<CallToolResult>;
|
|
13
|
+
/**
|
|
14
|
+
* Handler for fractary_docs_update
|
|
15
|
+
*/
|
|
16
|
+
export declare function handleDocsUpdate(params: {
|
|
17
|
+
id: string;
|
|
18
|
+
title?: string;
|
|
19
|
+
content?: string;
|
|
20
|
+
tags?: string[];
|
|
21
|
+
}, config: Config): Promise<CallToolResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Handler for fractary_docs_search
|
|
24
|
+
*/
|
|
25
|
+
export declare function handleDocsSearch(params: {
|
|
26
|
+
text?: string;
|
|
27
|
+
tags?: string[];
|
|
28
|
+
author?: string;
|
|
29
|
+
limit?: number;
|
|
30
|
+
}, config: Config): Promise<CallToolResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Handler for fractary_docs_export
|
|
33
|
+
*/
|
|
34
|
+
export declare function handleDocsExport(params: {
|
|
35
|
+
id: string;
|
|
36
|
+
format?: string;
|
|
37
|
+
}, config: Config): Promise<CallToolResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Handler for fractary_docs_list
|
|
40
|
+
*/
|
|
41
|
+
export declare function handleDocsList(params: {
|
|
42
|
+
tags?: string[];
|
|
43
|
+
author?: string;
|
|
44
|
+
limit?: number;
|
|
45
|
+
}, config: Config): Promise<CallToolResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Handler for fractary_docs_read
|
|
48
|
+
*/
|
|
49
|
+
export declare function handleDocsRead(params: {
|
|
50
|
+
id: string;
|
|
51
|
+
}, config: Config): Promise<CallToolResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Handler for fractary_docs_delete
|
|
54
|
+
*/
|
|
55
|
+
export declare function handleDocsDelete(params: {
|
|
56
|
+
id: string;
|
|
57
|
+
}, config: Config): Promise<CallToolResult>;
|
|
58
|
+
//# sourceMappingURL=docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/handlers/docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE;IACN,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB,EACD,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CAkBzB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE;IACN,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB,EACD,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CAmBzB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE;IACN,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EACD,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CAczB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE;IACN,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,EACD,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CAoBzB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE;IACN,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EACD,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CA6BzB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACtB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CAczB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACtB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CAczB"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { DocsManager } from '@fractary/core/docs';
|
|
2
|
+
import { successResult, errorResult } from './helpers.js';
|
|
3
|
+
/**
|
|
4
|
+
* Handler for fractary_docs_create
|
|
5
|
+
*/
|
|
6
|
+
export async function handleDocsCreate(params, config) {
|
|
7
|
+
try {
|
|
8
|
+
const manager = new DocsManager({ docsDir: config.docs?.docsDir || '.fractary/docs' });
|
|
9
|
+
const doc = await manager.createDoc(params.id, params.content, {
|
|
10
|
+
title: params.title,
|
|
11
|
+
type: params.type,
|
|
12
|
+
tags: params.tags || [],
|
|
13
|
+
}, 'markdown');
|
|
14
|
+
return successResult(doc);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
18
|
+
return errorResult(`Error creating doc: ${message}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Handler for fractary_docs_update
|
|
23
|
+
*/
|
|
24
|
+
export async function handleDocsUpdate(params, config) {
|
|
25
|
+
try {
|
|
26
|
+
const manager = new DocsManager({ docsDir: config.docs?.docsDir || '.fractary/docs' });
|
|
27
|
+
const metadata = {};
|
|
28
|
+
if (params.title)
|
|
29
|
+
metadata.title = params.title;
|
|
30
|
+
if (params.tags)
|
|
31
|
+
metadata.tags = params.tags;
|
|
32
|
+
const doc = await manager.updateDoc(params.id, params.content || '', metadata);
|
|
33
|
+
if (!doc) {
|
|
34
|
+
return errorResult(`Doc not found: ${params.id}`);
|
|
35
|
+
}
|
|
36
|
+
return successResult(doc);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
40
|
+
return errorResult(`Error updating doc: ${message}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Handler for fractary_docs_search
|
|
45
|
+
*/
|
|
46
|
+
export async function handleDocsSearch(params, config) {
|
|
47
|
+
try {
|
|
48
|
+
const manager = new DocsManager({ docsDir: config.docs?.docsDir || '.fractary/docs' });
|
|
49
|
+
const docs = await manager.searchDocs({
|
|
50
|
+
text: params.text,
|
|
51
|
+
tags: params.tags,
|
|
52
|
+
author: params.author,
|
|
53
|
+
limit: params.limit,
|
|
54
|
+
});
|
|
55
|
+
return successResult(docs);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
59
|
+
return errorResult(`Error searching docs: ${message}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Handler for fractary_docs_export
|
|
64
|
+
*/
|
|
65
|
+
export async function handleDocsExport(params, config) {
|
|
66
|
+
try {
|
|
67
|
+
const manager = new DocsManager({ docsDir: config.docs?.docsDir || '.fractary/docs' });
|
|
68
|
+
const doc = await manager.getDoc(params.id);
|
|
69
|
+
if (!doc) {
|
|
70
|
+
return errorResult(`Doc not found: ${params.id}`);
|
|
71
|
+
}
|
|
72
|
+
// For now, just return the doc content
|
|
73
|
+
// In a full implementation, this would convert to the requested format
|
|
74
|
+
return successResult({
|
|
75
|
+
id: params.id,
|
|
76
|
+
format: params.format || 'markdown',
|
|
77
|
+
content: doc.content,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
82
|
+
return errorResult(`Error exporting doc: ${message}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Handler for fractary_docs_list
|
|
87
|
+
*/
|
|
88
|
+
export async function handleDocsList(params, config) {
|
|
89
|
+
try {
|
|
90
|
+
const manager = new DocsManager({ docsDir: config.docs?.docsDir || '.fractary/docs' });
|
|
91
|
+
const docs = await manager.listDocs();
|
|
92
|
+
// Apply filters
|
|
93
|
+
let filteredDocs = docs;
|
|
94
|
+
if (params.author) {
|
|
95
|
+
filteredDocs = filteredDocs.filter(doc => doc.metadata.authors?.includes(params.author));
|
|
96
|
+
}
|
|
97
|
+
if (params.tags && params.tags.length > 0) {
|
|
98
|
+
filteredDocs = filteredDocs.filter(doc => params.tags.some(tag => doc.metadata.tags?.includes(tag)));
|
|
99
|
+
}
|
|
100
|
+
if (params.limit) {
|
|
101
|
+
filteredDocs = filteredDocs.slice(0, params.limit);
|
|
102
|
+
}
|
|
103
|
+
return successResult(filteredDocs);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
107
|
+
return errorResult(`Error listing docs: ${message}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Handler for fractary_docs_read
|
|
112
|
+
*/
|
|
113
|
+
export async function handleDocsRead(params, config) {
|
|
114
|
+
try {
|
|
115
|
+
const manager = new DocsManager({ docsDir: config.docs?.docsDir || '.fractary/docs' });
|
|
116
|
+
const doc = await manager.getDoc(params.id);
|
|
117
|
+
if (!doc) {
|
|
118
|
+
return errorResult(`Doc not found: ${params.id}`);
|
|
119
|
+
}
|
|
120
|
+
return successResult(doc);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
124
|
+
return errorResult(`Error reading doc: ${message}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Handler for fractary_docs_delete
|
|
129
|
+
*/
|
|
130
|
+
export async function handleDocsDelete(params, config) {
|
|
131
|
+
try {
|
|
132
|
+
const manager = new DocsManager({ docsDir: config.docs?.docsDir || '.fractary/docs' });
|
|
133
|
+
const deleted = await manager.deleteDoc(params.id);
|
|
134
|
+
if (!deleted) {
|
|
135
|
+
return errorResult(`Doc not found: ${params.id}`);
|
|
136
|
+
}
|
|
137
|
+
return successResult({ id: params.id, deleted: true });
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
141
|
+
return errorResult(`Error deleting doc: ${message}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../src/handlers/docs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAMC,EACD,MAAc;IAEd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