gitnexus 1.6.11-rc.12 → 1.6.11-rc.13
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/dist/cli/i18n/en.d.ts +1 -1
- package/dist/cli/i18n/en.js +1 -1
- package/dist/cli/i18n/resources.d.ts +1 -1
- package/dist/cli/i18n/zh-CN.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/server/api.js +4 -1
- package/dist/server/mcp-http.d.ts +8 -0
- package/dist/server/mcp-http.js +16 -1
- package/package.json +1 -1
package/dist/cli/i18n/en.d.ts
CHANGED
|
@@ -187,7 +187,7 @@ export declare const en: {
|
|
|
187
187
|
readonly 'help.option.serve.host': "Bind address (default: 127.0.0.1, use 0.0.0.0 for remote access)";
|
|
188
188
|
readonly 'help.option.mcp.http': "Serve MCP over HTTP instead of stdio (for remote clients)";
|
|
189
189
|
readonly 'help.option.mcp.host': "HTTP bind address (only with --http). Default: 127.0.0.1 (loopback). Use 0.0.0.0 to expose to all interfaces.";
|
|
190
|
-
readonly 'help.option.mcp.authToken': "Require this bearer token in the Authorization header (only with --http); may also be set via the GITNEXUS_MCP_AUTH_TOKEN env var. Required for a non-loopback bind (--host 0.0.0.0/::), which otherwise refuses to start.";
|
|
190
|
+
readonly 'help.option.mcp.authToken': "Require this bearer token in the Authorization header (only with --http); may also be set via the GITNEXUS_MCP_AUTH_TOKEN env var, which also enables MCP Bearer auth on gitnexus serve's /api/mcp route. Required for a non-loopback bind (--host 0.0.0.0/::), which otherwise refuses to start.";
|
|
191
191
|
readonly 'help.option.force.confirmation': "Skip confirmation prompt";
|
|
192
192
|
readonly 'help.option.uninstall.force': "Apply the changes (default is a dry-run preview)";
|
|
193
193
|
readonly 'help.option.clean.all': "Clean all indexed repos";
|
package/dist/cli/i18n/en.js
CHANGED
|
@@ -189,7 +189,7 @@ export const en = {
|
|
|
189
189
|
'help.option.serve.host': 'Bind address (default: 127.0.0.1, use 0.0.0.0 for remote access)',
|
|
190
190
|
'help.option.mcp.http': 'Serve MCP over HTTP instead of stdio (for remote clients)',
|
|
191
191
|
'help.option.mcp.host': 'HTTP bind address (only with --http). Default: 127.0.0.1 (loopback). Use 0.0.0.0 to expose to all interfaces.',
|
|
192
|
-
'help.option.mcp.authToken':
|
|
192
|
+
'help.option.mcp.authToken': "Require this bearer token in the Authorization header (only with --http); may also be set via the GITNEXUS_MCP_AUTH_TOKEN env var, which also enables MCP Bearer auth on gitnexus serve's /api/mcp route. Required for a non-loopback bind (--host 0.0.0.0/::), which otherwise refuses to start.",
|
|
193
193
|
'help.option.force.confirmation': 'Skip confirmation prompt',
|
|
194
194
|
'help.option.uninstall.force': 'Apply the changes (default is a dry-run preview)',
|
|
195
195
|
'help.option.clean.all': 'Clean all indexed repos',
|
|
@@ -188,7 +188,7 @@ export declare const cliResources: {
|
|
|
188
188
|
readonly 'help.option.serve.host': "Bind address (default: 127.0.0.1, use 0.0.0.0 for remote access)";
|
|
189
189
|
readonly 'help.option.mcp.http': "Serve MCP over HTTP instead of stdio (for remote clients)";
|
|
190
190
|
readonly 'help.option.mcp.host': "HTTP bind address (only with --http). Default: 127.0.0.1 (loopback). Use 0.0.0.0 to expose to all interfaces.";
|
|
191
|
-
readonly 'help.option.mcp.authToken': "Require this bearer token in the Authorization header (only with --http); may also be set via the GITNEXUS_MCP_AUTH_TOKEN env var. Required for a non-loopback bind (--host 0.0.0.0/::), which otherwise refuses to start.";
|
|
191
|
+
readonly 'help.option.mcp.authToken': "Require this bearer token in the Authorization header (only with --http); may also be set via the GITNEXUS_MCP_AUTH_TOKEN env var, which also enables MCP Bearer auth on gitnexus serve's /api/mcp route. Required for a non-loopback bind (--host 0.0.0.0/::), which otherwise refuses to start.";
|
|
192
192
|
readonly 'help.option.force.confirmation': "Skip confirmation prompt";
|
|
193
193
|
readonly 'help.option.uninstall.force': "Apply the changes (default is a dry-run preview)";
|
|
194
194
|
readonly 'help.option.clean.all': "Clean all indexed repos";
|
package/dist/cli/i18n/zh-CN.js
CHANGED
|
@@ -187,7 +187,7 @@ export const zhCN = {
|
|
|
187
187
|
'help.option.serve.host': '绑定地址(默认:127.0.0.1;远程访问可用 0.0.0.0)',
|
|
188
188
|
'help.option.mcp.http': '使用 HTTP 代替 stdio 提供 MCP 服务(适合远程客户端)',
|
|
189
189
|
'help.option.mcp.host': 'HTTP 绑定地址(仅与 --http 搭配使用)。默认:127.0.0.1(回环)。使用 0.0.0.0 向所有接口开放。',
|
|
190
|
-
'help.option.mcp.authToken': '要求 Authorization 头携带此 Bearer Token(仅与 --http 搭配使用);也可通过 GITNEXUS_MCP_AUTH_TOKEN
|
|
190
|
+
'help.option.mcp.authToken': '要求 Authorization 头携带此 Bearer Token(仅与 --http 搭配使用);也可通过 GITNEXUS_MCP_AUTH_TOKEN 环境变量设置,该变量同时为 gitnexus serve 的 /api/mcp 路由启用 MCP Bearer 认证。非回环绑定(--host 0.0.0.0/::)时必填,否则拒绝启动。',
|
|
191
191
|
'help.option.force.confirmation': '跳过确认提示',
|
|
192
192
|
'help.option.uninstall.force': '应用更改(默认仅为预演预览)',
|
|
193
193
|
'help.option.clean.all': '清理所有已索引仓库',
|
package/dist/cli/index.js
CHANGED
|
@@ -149,7 +149,7 @@ program
|
|
|
149
149
|
.option('--http', 'Serve MCP over HTTP instead of stdio (for remote clients)')
|
|
150
150
|
.option('-p, --port <port>', 'HTTP port (only with --http). Default: 3000', '3000')
|
|
151
151
|
.option('--host <host>', 'HTTP bind address (only with --http). Default: 127.0.0.1 (loopback). Use 0.0.0.0 to expose to all interfaces.', '127.0.0.1')
|
|
152
|
-
.option('--auth-token <token>',
|
|
152
|
+
.option('--auth-token <token>', "Require this bearer token in the Authorization header (only with --http); may also be set via the GITNEXUS_MCP_AUTH_TOKEN env var, which also enables MCP Bearer auth on gitnexus serve's /api/mcp route. Required for a non-loopback bind (--host 0.0.0.0/::), which otherwise refuses to start.")
|
|
153
153
|
.action(createLbugLazyAction(() => import('./mcp.js'), 'mcpCommand'));
|
|
154
154
|
program
|
|
155
155
|
.command('list')
|
package/dist/server/api.js
CHANGED
|
@@ -20,7 +20,7 @@ import { searchFTSFromLbug } from '../core/search/bm25-index.js';
|
|
|
20
20
|
import { hybridSearch } from '../core/search/hybrid-search.js';
|
|
21
21
|
import { ftsDegradedWarning } from '../core/search/fts-indexes.js';
|
|
22
22
|
import { LocalBackend } from '../mcp/local/local-backend.js';
|
|
23
|
-
import { mountMCPEndpoints } from './mcp-http.js';
|
|
23
|
+
import { installServeMcpAuth, mountMCPEndpoints } from './mcp-http.js';
|
|
24
24
|
import { fileURLToPath } from 'url';
|
|
25
25
|
import { isTerminalJobStatus, JobManager } from './analyze-job.js';
|
|
26
26
|
import { mountSSEProgress } from './sse-progress.js';
|
|
@@ -616,6 +616,9 @@ export const createServer = async (port, host = '127.0.0.1') => {
|
|
|
616
616
|
callback(null, isAllowedOrigin(origin));
|
|
617
617
|
},
|
|
618
618
|
}));
|
|
619
|
+
// Optional protocol-layer auth for the MCP route. Keep this before the
|
|
620
|
+
// global body parser so rejected requests do not consume the JSON budget.
|
|
621
|
+
installServeMcpAuth(app);
|
|
619
622
|
app.use(express.json({ limit: '10mb' }));
|
|
620
623
|
// Origin guard for write routes: loopback, the server's own bound host, and
|
|
621
624
|
// any configured public origin — prevents CSRF from other devices.
|
|
@@ -9,4 +9,12 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { Express } from 'express';
|
|
11
11
|
import type { LocalBackend } from '../mcp/local/local-backend.js';
|
|
12
|
+
/**
|
|
13
|
+
* Protect serve's /api/mcp route when the shared MCP bearer token is configured.
|
|
14
|
+
*
|
|
15
|
+
* This middleware must be installed before Express's global JSON parser so an
|
|
16
|
+
* unauthenticated request body is rejected before it is parsed. The standalone
|
|
17
|
+
* `gitnexus mcp --http` server resolves the same environment variable.
|
|
18
|
+
*/
|
|
19
|
+
export declare function installServeMcpAuth(app: Express, env?: NodeJS.ProcessEnv): boolean;
|
|
12
20
|
export declare function mountMCPEndpoints(app: Express, backend: LocalBackend): Promise<() => Promise<void>>;
|
package/dist/server/mcp-http.js
CHANGED
|
@@ -7,9 +7,24 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Used by server/api.ts to wire up the full web server.
|
|
9
9
|
*/
|
|
10
|
-
import { createStreamableHttpHandler } from '../mcp/http-transport.js';
|
|
10
|
+
import { createAuthMiddleware, createStreamableHttpHandler, resolveAuthToken, } from '../mcp/http-transport.js';
|
|
11
11
|
import { createMcpRepositoryPolicy } from '../mcp/repository-policy.js';
|
|
12
12
|
import { logger } from '../core/logger.js';
|
|
13
|
+
/**
|
|
14
|
+
* Protect serve's /api/mcp route when the shared MCP bearer token is configured.
|
|
15
|
+
*
|
|
16
|
+
* This middleware must be installed before Express's global JSON parser so an
|
|
17
|
+
* unauthenticated request body is rejected before it is parsed. The standalone
|
|
18
|
+
* `gitnexus mcp --http` server resolves the same environment variable.
|
|
19
|
+
*/
|
|
20
|
+
export function installServeMcpAuth(app, env = process.env) {
|
|
21
|
+
const authToken = resolveAuthToken(undefined, env);
|
|
22
|
+
if (!authToken)
|
|
23
|
+
return false;
|
|
24
|
+
app.use('/api/mcp', createAuthMiddleware(authToken));
|
|
25
|
+
logger.info('Bearer authentication enabled for serve /api/mcp');
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
13
28
|
export async function mountMCPEndpoints(app, backend) {
|
|
14
29
|
const repositoryPolicy = await createMcpRepositoryPolicy(backend);
|
|
15
30
|
const { handler, cleanup } = createStreamableHttpHandler(backend, { repositoryPolicy });
|
package/package.json
CHANGED