@gitcorenet/mcp 0.0.0-stage → 1.1.12
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 +63 -2
- package/bin/gitcore-mcp.js +4 -0
- package/package.json +41 -4
- package/server.json +52 -0
- package/src/index.js +430 -0
package/README.md
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@gitcorenet/mcp` — Official GitCore MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Official [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server for **[GitCore](https://gitcore.net)** — the sovereign, bare-metal Git platform built for parallel AI coding agent swarms, Virtual Stacked PR DAGs, Speculative Merge Queues, SARIF v2.1.0 code reviews, and air-gapped VPC deployments.
|
|
4
|
+
|
|
5
|
+
## High-Value Agent Primitives
|
|
6
|
+
|
|
7
|
+
| Tool | Description |
|
|
8
|
+
| :--- | :--- |
|
|
9
|
+
| `create_repo` | Create a public or private bare Git repository with instant Smart HTTP v2 clone URLs. |
|
|
10
|
+
| `push_stacked_pr` | Atomically commit multiple files onto a stacked feature branch on bare storage, open/update the PR, link `parentPrNumber` in the Virtual Stacked PR DAG, and attach agent attestation. |
|
|
11
|
+
| `enqueue_speculative_merge` | Enqueue a PR into GitCore's in-memory `git merge-tree --write-tree` Speculative Parallel Merge Queue (`merge`, `squash`, `rebase`). |
|
|
12
|
+
| `get_sarif_review` | Fetch OASIS SARIF v2.1.0 inline findings, machine-applicable code replacement suggestions, formal review status, and Anti-Ping-Pong circuit-breaker state. |
|
|
13
|
+
| `sign_agent_attestation` | Cryptographically sign and attach HMAC-SHA256 provenance (`agentId`, `model`, `runId`, `promptHash`, `confidenceScore`) plus optional PGP/Ed25519 client signatures. |
|
|
14
|
+
| `submit_sarif_review` | Post a structured SARIF v2.1.0 static analysis review onto a PR. |
|
|
15
|
+
| `get_pull_request_stack` | Inspect ancestor/descendant PRs and blockers in a Virtual Stacked PR DAG. |
|
|
16
|
+
| `search_public_repos` | Search public repositories hosted on GitCore. |
|
|
17
|
+
|
|
18
|
+
## Quickstart
|
|
19
|
+
|
|
20
|
+
### Option A: Remote Streamable HTTP (`https://mcp.gitcore.net/mcp`) — Zero Install
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"mcpServers": {
|
|
25
|
+
"gitcore": {
|
|
26
|
+
"url": "https://mcp.gitcore.net/mcp",
|
|
27
|
+
"headers": {
|
|
28
|
+
"Authorization": "Bearer gitcore_pat_YOUR_TOKEN_HERE"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Option B: Local `stdio` via `npx` (Cloud & Self-Hosted / Air-Gapped VPC)
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"mcpServers": {
|
|
40
|
+
"gitcore": {
|
|
41
|
+
"command": "npx",
|
|
42
|
+
"args": ["-y", "@gitcorenet/mcp"],
|
|
43
|
+
"env": {
|
|
44
|
+
"GITCORE_TOKEN": "gitcore_pat_YOUR_TOKEN_HERE",
|
|
45
|
+
"GITCORE_URL": "https://gitcore.net"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Claude Code One-Liner
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
claude mcp add --transport http gitcore https://mcp.gitcore.net/mcp --header "Authorization: Bearer $GITCORE_TOKEN"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Links
|
|
59
|
+
|
|
60
|
+
- **LLM Index**: https://gitcore.net/llms.txt
|
|
61
|
+
- **Full Technical Reference**: https://gitcore.net/llms-full.txt
|
|
62
|
+
- **OpenAPI 3.1 Spec**: https://gitcore.net/openapi.json
|
|
63
|
+
- **A2A Agent Card**: https://gitcore.net/.well-known/agent-card.json
|
|
64
|
+
- **Support**: `support@gitcore.com.ng` (Peer Capital Limited)
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitcorenet/mcp",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "1.1.12",
|
|
4
|
+
"mcpName": "io.github.christmasday/gitcore-mcp",
|
|
5
|
+
"description": "Official Model Context Protocol (MCP) server for GitCore — sovereign bare-metal Git hosting, Virtual Stacked PR DAGs, Speculative Merge Queues, SARIF v2.1.0 code reviews, and cryptographic agent attestation.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./src/index.js",
|
|
8
|
+
"bin": {
|
|
9
|
+
"gitcore-mcp": "bin/gitcore-mcp.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin/",
|
|
13
|
+
"src/",
|
|
14
|
+
"server.json",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"start": "node ./bin/gitcore-mcp.js"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"mcp",
|
|
22
|
+
"model-context-protocol",
|
|
23
|
+
"gitcore",
|
|
24
|
+
"git",
|
|
25
|
+
"stacked-prs",
|
|
26
|
+
"merge-queue",
|
|
27
|
+
"sarif",
|
|
28
|
+
"ai-agents",
|
|
29
|
+
"sovereign-cloud",
|
|
30
|
+
"air-gapped"
|
|
31
|
+
],
|
|
32
|
+
"author": "Peer Capital Limited <support@gitcore.com.ng>",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"homepage": "https://gitcore.net/llms.txt",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/christmasday/gitcore.git",
|
|
38
|
+
"directory": "packages/gitcore-mcp"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18.0.0"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.christmasday/gitcore-mcp",
|
|
4
|
+
"title": "GitCore Sovereign Git & Swarm Merge MCP Server",
|
|
5
|
+
"description": "Official GitCore MCP server for stacked PR DAGs, speculative merge queues, SARIF reviews, and agent provenance.",
|
|
6
|
+
"version": "1.1.12",
|
|
7
|
+
"websiteUrl": "https://gitcore.net",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/christmasday/gitcore",
|
|
10
|
+
"source": "github",
|
|
11
|
+
"subfolder": "packages/gitcore-mcp"
|
|
12
|
+
},
|
|
13
|
+
"packages": [
|
|
14
|
+
{
|
|
15
|
+
"registryType": "npm",
|
|
16
|
+
"registryBaseUrl": "https://registry.npmjs.org",
|
|
17
|
+
"identifier": "@gitcorenet/mcp",
|
|
18
|
+
"version": "1.1.12",
|
|
19
|
+
"transport": {
|
|
20
|
+
"type": "stdio"
|
|
21
|
+
},
|
|
22
|
+
"environmentVariables": [
|
|
23
|
+
{
|
|
24
|
+
"name": "GITCORE_TOKEN",
|
|
25
|
+
"description": "GitCore Personal Access Token (`gitcore_pat_...`) for authenticating write operations.",
|
|
26
|
+
"isRequired": true,
|
|
27
|
+
"isSecret": true
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "GITCORE_URL",
|
|
31
|
+
"description": "GitCore base URL (defaults to https://gitcore.net; override for self-hosted/air-gapped VPC instances).",
|
|
32
|
+
"isRequired": false,
|
|
33
|
+
"default": "https://gitcore.net"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"remotes": [
|
|
39
|
+
{
|
|
40
|
+
"type": "streamable-http",
|
|
41
|
+
"url": "https://mcp.gitcore.net/mcp",
|
|
42
|
+
"headers": [
|
|
43
|
+
{
|
|
44
|
+
"name": "Authorization",
|
|
45
|
+
"description": "Bearer Personal Access Token (`Bearer gitcore_pat_...`)",
|
|
46
|
+
"isRequired": false,
|
|
47
|
+
"isSecret": true
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @gitcorenet/mcp — Official Stdio MCP Client-Server Bridge for GitCore
|
|
3
|
+
*
|
|
4
|
+
* Works against both https://gitcore.net and air-gapped self-hosted Sovereign VPC instances.
|
|
5
|
+
* Zero external runtime dependencies (Node >= 18 built-in fetch + readline).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import readline from 'readline';
|
|
9
|
+
|
|
10
|
+
export const MCP_PROTOCOL_VERSION = '2025-06-18';
|
|
11
|
+
const SUPPORTED_VERSIONS = new Set(['2025-06-18', '2025-03-26', '2024-11-05']);
|
|
12
|
+
|
|
13
|
+
export const TOOLS = [
|
|
14
|
+
{
|
|
15
|
+
name: 'create_repo',
|
|
16
|
+
title: 'Create GitCore Repository',
|
|
17
|
+
description: 'Provision a new public or private bare Git repository on GitCore and return its Smart HTTP v2 clone URL, default branch, and API metadata.',
|
|
18
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
required: ['name'],
|
|
22
|
+
properties: {
|
|
23
|
+
owner: { type: 'string', description: 'Owner username or organization slug (defaults to authenticated user).' },
|
|
24
|
+
name: { type: 'string', description: 'Repository slug (e.g. "payment-router").' },
|
|
25
|
+
description: { type: 'string', description: 'Repository description.' },
|
|
26
|
+
defaultBranch: { type: 'string', default: 'main' },
|
|
27
|
+
isPrivate: { type: 'boolean', default: false },
|
|
28
|
+
initReadme: { type: 'boolean', default: true }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'push_stacked_pr',
|
|
34
|
+
title: 'Push Stacked Pull Request',
|
|
35
|
+
description: 'Atomically commit file changes onto a stacked feature branch on bare Git storage, create/update the Pull Request, link `parentPrNumber` into the Virtual Stacked PR DAG, and optionally attach cryptographic agent attestation.',
|
|
36
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
required: ['owner', 'repo', 'head', 'title'],
|
|
40
|
+
properties: {
|
|
41
|
+
owner: { type: 'string' },
|
|
42
|
+
repo: { type: 'string' },
|
|
43
|
+
head: { type: 'string', description: 'Feature/stacked branch name (e.g. "stack/01-schema").' },
|
|
44
|
+
base: { type: 'string', description: 'Target base branch (auto-resolved from `parentPrNumber` if omitted).' },
|
|
45
|
+
parentPrNumber: { type: 'integer', description: 'Optional parent PR number in the Virtual Stacked PR DAG.' },
|
|
46
|
+
title: { type: 'string' },
|
|
47
|
+
body: { type: 'string' },
|
|
48
|
+
draft: { type: 'boolean', default: false },
|
|
49
|
+
commitMessage: { type: 'string' },
|
|
50
|
+
files: {
|
|
51
|
+
type: 'array',
|
|
52
|
+
items: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
required: ['path'],
|
|
55
|
+
properties: {
|
|
56
|
+
path: { type: 'string' },
|
|
57
|
+
content: { type: 'string' },
|
|
58
|
+
delete: { type: 'boolean', default: false },
|
|
59
|
+
executable: { type: 'boolean', default: false }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
attestation: {
|
|
64
|
+
type: 'object',
|
|
65
|
+
properties: {
|
|
66
|
+
agentId: { type: 'string' },
|
|
67
|
+
model: { type: 'string' },
|
|
68
|
+
runId: { type: 'string' },
|
|
69
|
+
promptHash: { type: 'string' },
|
|
70
|
+
confidenceScore: { type: 'number', minimum: 0, maximum: 1 }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'enqueue_speculative_merge',
|
|
78
|
+
title: 'Enqueue Speculative Parallel Merge',
|
|
79
|
+
description: 'Add a Pull Request to GitCore Speculative Parallel Merge Queue (`git merge-tree --write-tree`), ejecting conflicting PRs without stalling healthy downstream PRs.',
|
|
80
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
|
|
81
|
+
inputSchema: {
|
|
82
|
+
type: 'object',
|
|
83
|
+
required: ['owner', 'repo', 'prNumber'],
|
|
84
|
+
properties: {
|
|
85
|
+
owner: { type: 'string' },
|
|
86
|
+
repo: { type: 'string' },
|
|
87
|
+
prNumber: { type: 'integer' },
|
|
88
|
+
mergeStrategy: { type: 'string', enum: ['merge', 'squash', 'rebase'], default: 'merge' },
|
|
89
|
+
commitTitle: { type: 'string' },
|
|
90
|
+
autoProcess: { type: 'boolean', default: true }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'get_sarif_review',
|
|
96
|
+
title: 'Get SARIF v2.1.0 Code Review & Circuit-Breaker Status',
|
|
97
|
+
description: 'Retrieve structured OASIS SARIF v2.1.0 inline findings, machine-applicable code replacement suggestions, formal review state, and Anti-Ping-Pong circuit-breaker status.',
|
|
98
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
99
|
+
inputSchema: {
|
|
100
|
+
type: 'object',
|
|
101
|
+
required: ['owner', 'repo', 'prNumber'],
|
|
102
|
+
properties: {
|
|
103
|
+
owner: { type: 'string' },
|
|
104
|
+
repo: { type: 'string' },
|
|
105
|
+
prNumber: { type: 'integer' }
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'sign_agent_attestation',
|
|
111
|
+
title: 'Sign & Attach Cryptographic Agent Attestation',
|
|
112
|
+
description: 'Cryptographically sign and attach HMAC-SHA256 provenance plus optional PGP/Ed25519 client detached signatures onto a Pull Request.',
|
|
113
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
114
|
+
inputSchema: {
|
|
115
|
+
type: 'object',
|
|
116
|
+
required: ['owner', 'repo', 'prNumber', 'agentId', 'model'],
|
|
117
|
+
properties: {
|
|
118
|
+
owner: { type: 'string' },
|
|
119
|
+
repo: { type: 'string' },
|
|
120
|
+
prNumber: { type: 'integer' },
|
|
121
|
+
agentId: { type: 'string' },
|
|
122
|
+
model: { type: 'string' },
|
|
123
|
+
runId: { type: 'string' },
|
|
124
|
+
promptHash: { type: 'string' },
|
|
125
|
+
confidenceScore: { type: 'number', minimum: 0, maximum: 1, default: 1.0 },
|
|
126
|
+
clientSignature: { type: 'string' },
|
|
127
|
+
clientSignatureAlgorithm: { type: 'string', enum: ['pgp', 'ed25519', 'ecdsa-p256', 'sigstore', 'custom'] },
|
|
128
|
+
clientPublicKey: { type: 'string' }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'submit_sarif_review',
|
|
134
|
+
title: 'Submit SARIF v2.1.0 Static Analysis Review',
|
|
135
|
+
description: 'Post an OASIS SARIF v2.1.0 report onto a Pull Request as structured inline review comments.',
|
|
136
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
|
|
137
|
+
inputSchema: {
|
|
138
|
+
type: 'object',
|
|
139
|
+
required: ['owner', 'repo', 'prNumber', 'sarif'],
|
|
140
|
+
properties: {
|
|
141
|
+
owner: { type: 'string' },
|
|
142
|
+
repo: { type: 'string' },
|
|
143
|
+
prNumber: { type: 'integer' },
|
|
144
|
+
sarif: { type: 'object' }
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'get_pull_request_stack',
|
|
150
|
+
title: 'Inspect Virtual Stacked PR DAG',
|
|
151
|
+
description: 'Retrieve ancestor PRs, descendant PRs, rebase status, and merge blockers for a Pull Request.',
|
|
152
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
153
|
+
inputSchema: {
|
|
154
|
+
type: 'object',
|
|
155
|
+
required: ['owner', 'repo', 'prNumber'],
|
|
156
|
+
properties: {
|
|
157
|
+
owner: { type: 'string' },
|
|
158
|
+
repo: { type: 'string' },
|
|
159
|
+
prNumber: { type: 'integer' }
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: 'search_public_repos',
|
|
165
|
+
title: 'Search Public GitCore Repositories',
|
|
166
|
+
description: 'List and filter public repositories on GitCore.',
|
|
167
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
168
|
+
inputSchema: {
|
|
169
|
+
type: 'object',
|
|
170
|
+
properties: {
|
|
171
|
+
query: { type: 'string' }
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
];
|
|
176
|
+
|
|
177
|
+
function getConfig() {
|
|
178
|
+
const baseUrl = String(process.env.GITCORE_URL || process.env.GITCORE_BASE_URL || 'https://gitcore.net').replace(/\/+$/, '');
|
|
179
|
+
const token = String(process.env.GITCORE_TOKEN || process.env.GITCORE_PAT || '').trim();
|
|
180
|
+
return { baseUrl, token };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function gitcoreApi(pathname, { method = 'GET', body = undefined } = {}) {
|
|
184
|
+
const { baseUrl, token } = getConfig();
|
|
185
|
+
const headers = {
|
|
186
|
+
'Accept': 'application/json',
|
|
187
|
+
'User-Agent': '@gitcorenet/mcp/1.1.12'
|
|
188
|
+
};
|
|
189
|
+
if (token) {
|
|
190
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
191
|
+
}
|
|
192
|
+
if (body !== undefined) {
|
|
193
|
+
headers['Content-Type'] = 'application/json';
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const res = await fetch(`${baseUrl}${pathname}`, {
|
|
197
|
+
method,
|
|
198
|
+
headers,
|
|
199
|
+
body: body !== undefined ? JSON.stringify(body) : undefined
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
const contentType = res.headers.get('content-type') || '';
|
|
203
|
+
const data = contentType.includes('application/json')
|
|
204
|
+
? await res.json()
|
|
205
|
+
: await res.text();
|
|
206
|
+
|
|
207
|
+
if (!res.ok) {
|
|
208
|
+
const errMsg = typeof data === 'object' && data?.error ? data.error : `HTTP ${res.status}: ${typeof data === 'string' ? data : JSON.stringify(data)}`;
|
|
209
|
+
throw new Error(errMsg);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return data;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async function callToolOverRest(name, args = {}) {
|
|
216
|
+
const { baseUrl } = getConfig();
|
|
217
|
+
switch (name) {
|
|
218
|
+
case 'create_repo': {
|
|
219
|
+
const created = await gitcoreApi('/api/repos', {
|
|
220
|
+
method: 'POST',
|
|
221
|
+
body: {
|
|
222
|
+
owner: args.owner,
|
|
223
|
+
name: args.name,
|
|
224
|
+
description: args.description || '',
|
|
225
|
+
defaultBranch: args.defaultBranch || 'main',
|
|
226
|
+
isPrivate: Boolean(args.isPrivate),
|
|
227
|
+
initReadme: args.initReadme !== false
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
const owner = created.owner || args.owner;
|
|
231
|
+
return {
|
|
232
|
+
...created,
|
|
233
|
+
cloneUrl: created.cloneUrl || `${baseUrl}/${owner}/${args.name}.git`,
|
|
234
|
+
webUrl: `${baseUrl}/${owner}/${args.name}`
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
case 'push_stacked_pr':
|
|
239
|
+
return await gitcoreApi(`/api/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}/pulls/stacked`, {
|
|
240
|
+
method: 'POST',
|
|
241
|
+
body: {
|
|
242
|
+
head: args.head,
|
|
243
|
+
base: args.base || null,
|
|
244
|
+
parentPrNumber: args.parentPrNumber || null,
|
|
245
|
+
title: args.title,
|
|
246
|
+
body: args.body || '',
|
|
247
|
+
draft: Boolean(args.draft),
|
|
248
|
+
commitMessage: args.commitMessage || null,
|
|
249
|
+
files: args.files || null,
|
|
250
|
+
attestation: args.attestation || null
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
case 'enqueue_speculative_merge':
|
|
255
|
+
return await gitcoreApi(`/api/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}/pulls/${encodeURIComponent(args.prNumber)}/queue`, {
|
|
256
|
+
method: 'POST',
|
|
257
|
+
body: {
|
|
258
|
+
mergeStrategy: args.mergeStrategy || 'merge',
|
|
259
|
+
commitTitle: args.commitTitle || null,
|
|
260
|
+
autoProcess: args.autoProcess !== false
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
case 'get_sarif_review':
|
|
265
|
+
return await gitcoreApi(`/api/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}/pulls/${encodeURIComponent(args.prNumber)}/reviews/sarif`);
|
|
266
|
+
|
|
267
|
+
case 'sign_agent_attestation': {
|
|
268
|
+
const { owner, repo, prNumber, ...attestation } = args;
|
|
269
|
+
return await gitcoreApi(`/api/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/pulls/${encodeURIComponent(prNumber)}/attestation`, {
|
|
270
|
+
method: 'POST',
|
|
271
|
+
body: attestation
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
case 'submit_sarif_review':
|
|
276
|
+
return await gitcoreApi(`/api/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}/pulls/${encodeURIComponent(args.prNumber)}/reviews/sarif`, {
|
|
277
|
+
method: 'POST',
|
|
278
|
+
body: { sarif: args.sarif }
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
case 'get_pull_request_stack':
|
|
282
|
+
return await gitcoreApi(`/api/repos/${encodeURIComponent(args.owner)}/${encodeURIComponent(args.repo)}/pulls/${encodeURIComponent(args.prNumber)}/stack`);
|
|
283
|
+
|
|
284
|
+
case 'search_public_repos': {
|
|
285
|
+
const q = args.query ? `?q=${encodeURIComponent(args.query)}` : '';
|
|
286
|
+
const explore = await gitcoreApi(`/api/explore${q}`);
|
|
287
|
+
const qLower = String(args.query || '').toLowerCase().trim();
|
|
288
|
+
const filtered = (explore.repos || []).filter(r =>
|
|
289
|
+
!qLower || `${r.owner}/${r.name} ${r.description || ''}`.toLowerCase().includes(qLower)
|
|
290
|
+
);
|
|
291
|
+
return { count: filtered.length, repositories: filtered };
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
default:
|
|
295
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export async function handleJsonRpcMessage(msg) {
|
|
300
|
+
if (!msg || typeof msg !== 'object' || msg.jsonrpc !== '2.0') {
|
|
301
|
+
return { jsonrpc: '2.0', id: msg?.id ?? null, error: { code: -32600, message: 'Invalid JSON-RPC 2.0 request' } };
|
|
302
|
+
}
|
|
303
|
+
if (msg.id === undefined) return null; // Notification
|
|
304
|
+
|
|
305
|
+
const { id, method, params = {} } = msg;
|
|
306
|
+
const { baseUrl } = getConfig();
|
|
307
|
+
|
|
308
|
+
try {
|
|
309
|
+
switch (method) {
|
|
310
|
+
case 'initialize': {
|
|
311
|
+
const negotiated = SUPPORTED_VERSIONS.has(params?.protocolVersion)
|
|
312
|
+
? params.protocolVersion
|
|
313
|
+
: MCP_PROTOCOL_VERSION;
|
|
314
|
+
return {
|
|
315
|
+
jsonrpc: '2.0',
|
|
316
|
+
id,
|
|
317
|
+
result: {
|
|
318
|
+
protocolVersion: negotiated,
|
|
319
|
+
capabilities: {
|
|
320
|
+
tools: { listChanged: false },
|
|
321
|
+
resources: { subscribe: false, listChanged: false }
|
|
322
|
+
},
|
|
323
|
+
serverInfo: {
|
|
324
|
+
name: '@gitcorenet/mcp',
|
|
325
|
+
title: 'GitCore Sovereign Git & Swarm Merge MCP Server',
|
|
326
|
+
version: '1.1.12'
|
|
327
|
+
},
|
|
328
|
+
instructions: 'Use `create_repo`, `push_stacked_pr`, `sign_agent_attestation`, `get_sarif_review`, and `enqueue_speculative_merge` to ship conflict-free stacked PRs on GitCore.'
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
case 'ping':
|
|
334
|
+
return { jsonrpc: '2.0', id, result: {} };
|
|
335
|
+
|
|
336
|
+
case 'tools/list':
|
|
337
|
+
return { jsonrpc: '2.0', id, result: { tools: TOOLS } };
|
|
338
|
+
|
|
339
|
+
case 'tools/call': {
|
|
340
|
+
try {
|
|
341
|
+
const result = await callToolOverRest(params?.name, params?.arguments || {});
|
|
342
|
+
return {
|
|
343
|
+
jsonrpc: '2.0',
|
|
344
|
+
id,
|
|
345
|
+
result: {
|
|
346
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
347
|
+
structuredContent: result,
|
|
348
|
+
isError: false
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
} catch (err) {
|
|
352
|
+
return {
|
|
353
|
+
jsonrpc: '2.0',
|
|
354
|
+
id,
|
|
355
|
+
result: {
|
|
356
|
+
content: [{ type: 'text', text: JSON.stringify({ error: err.message }, null, 2) }],
|
|
357
|
+
isError: true
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
case 'resources/list':
|
|
364
|
+
return {
|
|
365
|
+
jsonrpc: '2.0',
|
|
366
|
+
id,
|
|
367
|
+
result: {
|
|
368
|
+
resources: [
|
|
369
|
+
{ uri: 'gitcore://llms.txt', name: 'GitCore LLM Index', mimeType: 'text/markdown' },
|
|
370
|
+
{ uri: 'gitcore://llms-full.txt', name: 'GitCore Full Reference', mimeType: 'text/markdown' },
|
|
371
|
+
{ uri: 'gitcore://openapi.json', name: 'GitCore OpenAPI 3.1 Spec', mimeType: 'application/json' }
|
|
372
|
+
]
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
case 'resources/read': {
|
|
377
|
+
const uri = params?.uri;
|
|
378
|
+
const map = {
|
|
379
|
+
'gitcore://llms.txt': ['/llms.txt', 'text/markdown'],
|
|
380
|
+
'gitcore://llms-full.txt': ['/llms-full.txt', 'text/markdown'],
|
|
381
|
+
'gitcore://openapi.json': ['/openapi.json', 'application/json']
|
|
382
|
+
};
|
|
383
|
+
if (!map[uri]) {
|
|
384
|
+
return { jsonrpc: '2.0', id, error: { code: -32602, message: `Unknown resource URI: ${uri}` } };
|
|
385
|
+
}
|
|
386
|
+
const [pathname, mimeType] = map[uri];
|
|
387
|
+
const res = await fetch(`${baseUrl}${pathname}`);
|
|
388
|
+
const text = await res.text();
|
|
389
|
+
return { jsonrpc: '2.0', id, result: { contents: [{ uri, mimeType, text }] } };
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
default:
|
|
393
|
+
return { jsonrpc: '2.0', id, error: { code: -32601, message: `Method not found: ${method}` } };
|
|
394
|
+
}
|
|
395
|
+
} catch (err) {
|
|
396
|
+
return { jsonrpc: '2.0', id, error: { code: -32603, message: err.message } };
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export function startStdioMcpServer() {
|
|
401
|
+
const rl = readline.createInterface({
|
|
402
|
+
input: process.stdin,
|
|
403
|
+
terminal: false
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
rl.on('line', async (line) => {
|
|
407
|
+
const trimmed = line.trim();
|
|
408
|
+
if (!trimmed) return;
|
|
409
|
+
try {
|
|
410
|
+
const parsed = JSON.parse(trimmed);
|
|
411
|
+
if (Array.isArray(parsed)) {
|
|
412
|
+
const out = [];
|
|
413
|
+
for (const item of parsed) {
|
|
414
|
+
const r = await handleJsonRpcMessage(item);
|
|
415
|
+
if (r) out.push(r);
|
|
416
|
+
}
|
|
417
|
+
if (out.length > 0) process.stdout.write(`${JSON.stringify(out)}\n`);
|
|
418
|
+
} else {
|
|
419
|
+
const response = await handleJsonRpcMessage(parsed);
|
|
420
|
+
if (response) process.stdout.write(`${JSON.stringify(response)}\n`);
|
|
421
|
+
}
|
|
422
|
+
} catch (err) {
|
|
423
|
+
process.stdout.write(`${JSON.stringify({
|
|
424
|
+
jsonrpc: '2.0',
|
|
425
|
+
id: null,
|
|
426
|
+
error: { code: -32700, message: `Parse error: ${err.message}` }
|
|
427
|
+
})}\n`);
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
}
|