@capybara-hq/plugin-connector-mcp 0.1.0-rc.10 → 0.1.0-rc.11
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/.capybara-plugin/plugin.json +4 -28
- package/dist/index.mjs +28 -28
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "connector-mcp",
|
|
4
|
-
"version": "0.1.0-rc.
|
|
4
|
+
"version": "0.1.0-rc.11",
|
|
5
5
|
"publisher": "Capybara",
|
|
6
6
|
"description": "MCP connector (connector@1): tools and resources of remote MCP servers over Streamable HTTP",
|
|
7
7
|
"displayName": {
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"entry": "./dist/index.mjs",
|
|
15
15
|
"manifest": {
|
|
16
16
|
"name": "connector-mcp",
|
|
17
|
-
"version": "0.1.0-rc.
|
|
18
|
-
"sdk": "^0.1.0-rc.
|
|
17
|
+
"version": "0.1.0-rc.11",
|
|
18
|
+
"sdk": "^0.1.0-rc.29",
|
|
19
19
|
"provides": [
|
|
20
20
|
"connector@1"
|
|
21
21
|
],
|
|
@@ -23,33 +23,9 @@
|
|
|
23
23
|
"optional": [],
|
|
24
24
|
"permissions": {},
|
|
25
25
|
"config": {
|
|
26
|
-
"deployment": [
|
|
27
|
-
{
|
|
28
|
-
"path": "allowInsecureLoopback",
|
|
29
|
-
"secret": false,
|
|
30
|
-
"hot": false
|
|
31
|
-
}
|
|
32
|
-
],
|
|
26
|
+
"deployment": [],
|
|
33
27
|
"org": []
|
|
34
28
|
}
|
|
35
|
-
},
|
|
36
|
-
"configSchemas": {
|
|
37
|
-
"deployment": {
|
|
38
|
-
"type": "object",
|
|
39
|
-
"properties": {
|
|
40
|
-
"allowInsecureLoopback": {
|
|
41
|
-
"default": false,
|
|
42
|
-
"type": "boolean",
|
|
43
|
-
"x-ui": {
|
|
44
|
-
"label": {
|
|
45
|
-
"zh": "允许本机 http 端点",
|
|
46
|
-
"en": "Allow loopback http endpoints"
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
"title": "Allow loopback http endpoints"
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
29
|
}
|
|
54
30
|
}
|
|
55
31
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -7305,11 +7305,11 @@ var require_content_type = __commonJS({
|
|
|
7305
7305
|
});
|
|
7306
7306
|
|
|
7307
7307
|
// src/index.ts
|
|
7308
|
-
import { CONNECTOR_EXTENSION_POINT, defineExtension
|
|
7309
|
-
import { z as z4 } from "zod";
|
|
7308
|
+
import { CONNECTOR_EXTENSION_POINT, defineExtension } from "@capybara-hq/plugin-sdk";
|
|
7310
7309
|
|
|
7311
7310
|
// src/session.ts
|
|
7312
7311
|
import {
|
|
7312
|
+
isNetDeniedError,
|
|
7313
7313
|
ToolError
|
|
7314
7314
|
} from "@capybara-hq/plugin-sdk";
|
|
7315
7315
|
|
|
@@ -12314,23 +12314,18 @@ var REQUEST_TIMEOUT_MS = 36e5;
|
|
|
12314
12314
|
var MAX_PAGES = 100;
|
|
12315
12315
|
var MAX_LOGGED_BODY = 1e3;
|
|
12316
12316
|
var CREDENTIAL_HEADERS = /* @__PURE__ */ new Set(["authorization", "proxy-authorization", "cookie"]);
|
|
12317
|
-
var
|
|
12318
|
-
var isLoopbackHttp = (u) => u.protocol === "http:" && LOOPBACK_HOSTS.has(u.hostname);
|
|
12319
|
-
var urlAllowed = (raw, allowInsecureLoopback) => {
|
|
12317
|
+
var urlAllowed = (raw) => {
|
|
12320
12318
|
let u;
|
|
12321
12319
|
try {
|
|
12322
12320
|
u = new URL(raw);
|
|
12323
12321
|
} catch {
|
|
12324
12322
|
return true;
|
|
12325
12323
|
}
|
|
12326
|
-
|
|
12327
|
-
return allowInsecureLoopback && isLoopbackHttp(u);
|
|
12324
|
+
return u.protocol === "https:" || u.protocol === "http:";
|
|
12328
12325
|
};
|
|
12329
|
-
function endpointSchema(
|
|
12326
|
+
function endpointSchema() {
|
|
12330
12327
|
return z3.object({
|
|
12331
|
-
url: z3.url().refine(
|
|
12332
|
-
message: allowInsecureLoopback ? "URL must use https (plain http is only allowed for 127.0.0.1, localhost and [::1])" : "URL must use https"
|
|
12333
|
-
}),
|
|
12328
|
+
url: z3.url().refine(urlAllowed, { message: "URL must use http or https" }),
|
|
12334
12329
|
headers: z3.record(z3.string(), z3.string()).default({}).superRefine((h, ctx) => {
|
|
12335
12330
|
for (const name of Object.keys(h)) {
|
|
12336
12331
|
if (CREDENTIAL_HEADERS.has(name.toLowerCase())) {
|
|
@@ -12344,6 +12339,7 @@ function endpointSchema(allowInsecureLoopback) {
|
|
|
12344
12339
|
})
|
|
12345
12340
|
});
|
|
12346
12341
|
}
|
|
12342
|
+
var netDeniedText = (host, reason) => `The request to ${host || "the app's server"} was refused by the platform's network rules: ${reason} Ask an administrator to check the app endpoint URL.`;
|
|
12347
12343
|
var redirectText = (status) => `The app's server responded with a redirect (HTTP ${status}); redirects are not followed. Ask an administrator to check the app endpoint URL.`;
|
|
12348
12344
|
var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
12349
12345
|
var TITLE_MAX = 80;
|
|
@@ -12475,7 +12471,7 @@ async function guarded(work) {
|
|
|
12475
12471
|
throw mapError(e);
|
|
12476
12472
|
}
|
|
12477
12473
|
}
|
|
12478
|
-
function authedFetch(endpoint, args, log) {
|
|
12474
|
+
function authedFetch(net, endpoint, args, log) {
|
|
12479
12475
|
return async (input, init) => {
|
|
12480
12476
|
const method = (init?.method ?? "GET").toUpperCase();
|
|
12481
12477
|
const send = async () => {
|
|
@@ -12486,7 +12482,16 @@ function authedFetch(endpoint, args, log) {
|
|
|
12486
12482
|
for (const [k, v] of Object.entries(endpoint.headers)) if (!headers.has(k)) headers.set(k, v);
|
|
12487
12483
|
for (const [k, v] of Object.entries(inj.headers)) headers.set(k, v);
|
|
12488
12484
|
const signal = init?.signal ? AbortSignal.any([init.signal, args.signal]) : args.signal;
|
|
12489
|
-
|
|
12485
|
+
try {
|
|
12486
|
+
return await net(
|
|
12487
|
+
url2.toString(),
|
|
12488
|
+
{ ...init, headers, signal, redirect: "manual" },
|
|
12489
|
+
{ orgId: args.orgId }
|
|
12490
|
+
);
|
|
12491
|
+
} catch (e) {
|
|
12492
|
+
if (isNetDeniedError(e)) throw new ToolError(netDeniedText(e.host, e.message));
|
|
12493
|
+
throw e;
|
|
12494
|
+
}
|
|
12490
12495
|
};
|
|
12491
12496
|
const noRedirect = async (r) => {
|
|
12492
12497
|
if (r.status >= 300 && r.status < 400) {
|
|
@@ -12513,9 +12518,9 @@ function authedFetch(endpoint, args, log) {
|
|
|
12513
12518
|
return res;
|
|
12514
12519
|
};
|
|
12515
12520
|
}
|
|
12516
|
-
async function openSession(endpoint, args, log) {
|
|
12521
|
+
async function openSession(net, endpoint, args, log) {
|
|
12517
12522
|
const transport = new StreamableHTTPClientTransport(new URL(endpoint.url), {
|
|
12518
|
-
fetch: authedFetch(endpoint, args, log)
|
|
12523
|
+
fetch: authedFetch(net, endpoint, args, log)
|
|
12519
12524
|
});
|
|
12520
12525
|
const onElicit = args.onElicit;
|
|
12521
12526
|
const client = new Client(CLIENT_INFO, {
|
|
@@ -12657,32 +12662,27 @@ async function openSession(endpoint, args, log) {
|
|
|
12657
12662
|
return session;
|
|
12658
12663
|
}
|
|
12659
12664
|
function createMcpConnector(deps) {
|
|
12660
|
-
const schema = endpointSchema(
|
|
12665
|
+
const schema = endpointSchema();
|
|
12661
12666
|
return {
|
|
12662
12667
|
kind: "mcp",
|
|
12663
12668
|
endpointSchema: schema,
|
|
12664
|
-
open: (args) => openSession(schema.parse(args.endpoint), args, deps.log)
|
|
12669
|
+
open: (args) => openSession(deps.fetch, schema.parse(args.endpoint), args, deps.log)
|
|
12665
12670
|
};
|
|
12666
12671
|
}
|
|
12667
12672
|
|
|
12668
12673
|
// src/index.ts
|
|
12669
|
-
var DeploymentConfig = z4.object({
|
|
12670
|
-
/** 允许端点用本机 http(127.0.0.1 / localhost / [::1]),仅供开发与测试;默认关闭,生产只接受 https。 */
|
|
12671
|
-
allowInsecureLoopback: ui(z4.boolean().default(false), {
|
|
12672
|
-
label: { zh: "允许本机 http 端点", en: "Allow loopback http endpoints" }
|
|
12673
|
-
})
|
|
12674
|
-
});
|
|
12675
12674
|
var index_default = defineExtension({
|
|
12676
12675
|
name: "connector-mcp",
|
|
12677
|
-
version: "0.1.0-rc.
|
|
12678
|
-
sdk: "^0.1.0-rc.
|
|
12676
|
+
version: "0.1.0-rc.11",
|
|
12677
|
+
sdk: "^0.1.0-rc.29",
|
|
12679
12678
|
provides: [CONNECTOR_EXTENSION_POINT],
|
|
12680
|
-
config: { deployment: DeploymentConfig },
|
|
12681
12679
|
setup(ctx) {
|
|
12682
|
-
const { allowInsecureLoopback } = DeploymentConfig.parse(ctx.config ?? {});
|
|
12683
12680
|
ctx.provide(
|
|
12684
12681
|
CONNECTOR_EXTENSION_POINT,
|
|
12685
|
-
createMcpConnector({
|
|
12682
|
+
createMcpConnector({
|
|
12683
|
+
log: ctx.log,
|
|
12684
|
+
fetch: (url2, init, opts) => ctx.net.fetch(url2, init, opts)
|
|
12685
|
+
})
|
|
12686
12686
|
);
|
|
12687
12687
|
}
|
|
12688
12688
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/plugin-connector-mcp",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "MCP connector (connector@1): tools and resources of remote MCP servers over Streamable HTTP",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
".": "./dist/index.mjs"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
18
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.29",
|
|
19
19
|
"zod": "^4.6.7"
|
|
20
20
|
}
|
|
21
21
|
}
|