@yaks/mcp-client 0.0.0-stage → 0.2.36
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 +202 -0
- package/README.md +174 -2
- package/_dist/mod.d.ts +90 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/oauth.d.ts +46 -0
- package/_dist/oauth.d.ts.map +1 -0
- package/_dist/servers.d.ts +11 -0
- package/_dist/servers.d.ts.map +1 -0
- package/_dist/vocab.d.ts +6 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/deno.json +1 -0
- package/mod.js +371 -0
- package/mod.js.map +1 -0
- package/mod.ts +492 -0
- package/oauth.js +95 -0
- package/oauth.js.map +1 -0
- package/oauth.ts +140 -0
- package/package.json +30 -4
- package/servers.js +94 -0
- package/servers.js.map +1 -0
- package/servers.ts +93 -0
- package/vocab.js +16 -0
- package/vocab.js.map +1 -0
- package/vocab.json +81 -0
- package/vocab.ts +17 -0
package/oauth.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/** Where an MCP server signs in, found the way the MCP spec says: its
|
|
2
|
+
* protected-resource metadata (RFC 9728) names the authorization server, whose
|
|
3
|
+
* own metadata (RFC 8414) names the endpoints, and a public client is named
|
|
4
|
+
* there by the host's own metadata document where the server takes one (a
|
|
5
|
+
* Client ID Metadata Document, its URL the client's id), else registers there
|
|
6
|
+
* (RFC 7591), when the host has none. What comes back is data, an
|
|
7
|
+
* integration as @yaks/connections takes it; the sign-in, the tokens and their
|
|
8
|
+
* refresh are @yaks/oauth's over that data. No UI, storage or session. */
|
|
9
|
+
|
|
10
|
+
// The SDK's discovery and registration, imported when a sign-in is looked for
|
|
11
|
+
// rather than when this module is (./mod.ts says why).
|
|
12
|
+
let auth = () =>
|
|
13
|
+
import('@modelcontextprotocol/sdk/client/auth.js') as Promise<
|
|
14
|
+
typeof import('npm:@modelcontextprotocol/sdk@^1.29.0/client/auth')
|
|
15
|
+
>
|
|
16
|
+
|
|
17
|
+
export type AuthorizationChallenge = {
|
|
18
|
+
resourceMetadataUrl?: string
|
|
19
|
+
scope?: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** An MCP server's sign-in, as data, and how to register a client with it. */
|
|
23
|
+
export type Found = {
|
|
24
|
+
integration: {
|
|
25
|
+
name: string
|
|
26
|
+
authorize: string
|
|
27
|
+
token: string
|
|
28
|
+
userinfo?: string
|
|
29
|
+
scopes?: string[]
|
|
30
|
+
resource: string
|
|
31
|
+
issuer?: string
|
|
32
|
+
hosts: string[]
|
|
33
|
+
}
|
|
34
|
+
/** a public client for `redirect`: the host's metadata document where the
|
|
35
|
+
* server takes one, else one registered now; its id */
|
|
36
|
+
register: (redirect: string) => Promise<string>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A public client's metadata (RFC 7591), and its id where it is a
|
|
40
|
+
* document's URL. */
|
|
41
|
+
export type ClientDocument = {
|
|
42
|
+
client_id?: string
|
|
43
|
+
client_name: string
|
|
44
|
+
redirect_uris: string[]
|
|
45
|
+
grant_types: string[]
|
|
46
|
+
response_types: string[]
|
|
47
|
+
token_endpoint_auth_method: string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** What the host's public client says of itself, returning to `redirect`:
|
|
51
|
+
* what it registers with (RFC 7591), and its metadata document, served at
|
|
52
|
+
* `id`, the URL that is its id where a server takes one.
|
|
53
|
+
*
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { assertEquals } from '@std/assert'
|
|
56
|
+
* let doc = client('https://h.test/oauth/client.json', 'https://h.test/cb')
|
|
57
|
+
* assertEquals([doc.client_id, doc.redirect_uris], [
|
|
58
|
+
* 'https://h.test/oauth/client.json', ['https://h.test/cb'],
|
|
59
|
+
* ])
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export const client = (
|
|
63
|
+
id: string | undefined,
|
|
64
|
+
redirect: string,
|
|
65
|
+
): ClientDocument => ({
|
|
66
|
+
...id ? { client_id: safe(id) } : {},
|
|
67
|
+
client_name: 'yaks.app MCP client',
|
|
68
|
+
redirect_uris: [safe(redirect)],
|
|
69
|
+
grant_types: ['authorization_code', 'refresh_token'],
|
|
70
|
+
response_types: ['code'],
|
|
71
|
+
token_endpoint_auth_method: 'none',
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
export class AuthorizationError extends Error {}
|
|
75
|
+
|
|
76
|
+
// HTTPS, or HTTP on this machine: what a code, a token or a registration may
|
|
77
|
+
// travel over.
|
|
78
|
+
const safe = (url: string | URL): string => {
|
|
79
|
+
const u = new URL(url)
|
|
80
|
+
if (
|
|
81
|
+
u.username || u.password || (u.protocol !== 'https:' &&
|
|
82
|
+
!(u.protocol === 'http:' &&
|
|
83
|
+
['127.0.0.1', 'localhost', '[::1]'].includes(u.hostname)))
|
|
84
|
+
) throw new AuthorizationError('OAuth requires HTTPS or a loopback URL')
|
|
85
|
+
return u.href
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Find where the server at `url` signs in. The integration is named for the
|
|
89
|
+
* server, sends its tokens to the server's host alone, and asks for the grant
|
|
90
|
+
* to be for the server (RFC 8707). `document` is the URL the host serves its
|
|
91
|
+
* client's metadata document at ({@link client}), where it serves one. */
|
|
92
|
+
export const discover = async (
|
|
93
|
+
url: string,
|
|
94
|
+
challenge: AuthorizationChallenge = {},
|
|
95
|
+
fetch: typeof globalThis.fetch = globalThis.fetch,
|
|
96
|
+
document?: string,
|
|
97
|
+
): Promise<Found> => {
|
|
98
|
+
const fetchFn: typeof globalThis.fetch = (input, init) =>
|
|
99
|
+
fetch(safe(input instanceof Request ? input.url : String(input)), {
|
|
100
|
+
...init,
|
|
101
|
+
redirect: 'manual',
|
|
102
|
+
signal: AbortSignal.timeout(30000),
|
|
103
|
+
})
|
|
104
|
+
const { discoverOAuthServerInfo, registerClient } = await auth()
|
|
105
|
+
const info = await discoverOAuthServerInfo(safe(url), {
|
|
106
|
+
resourceMetadataUrl: challenge.resourceMetadataUrl
|
|
107
|
+
? new URL(challenge.resourceMetadataUrl)
|
|
108
|
+
: undefined,
|
|
109
|
+
fetchFn,
|
|
110
|
+
})
|
|
111
|
+
const meta = info.authorizationServerMetadata
|
|
112
|
+
if (!meta) throw new AuthorizationError('The server names no sign-in')
|
|
113
|
+
const scope = challenge.scope ??
|
|
114
|
+
info.resourceMetadata?.scopes_supported?.join(' ')
|
|
115
|
+
return {
|
|
116
|
+
integration: {
|
|
117
|
+
name: url,
|
|
118
|
+
authorize: safe(meta.authorization_endpoint),
|
|
119
|
+
token: safe(meta.token_endpoint),
|
|
120
|
+
...typeof meta.userinfo_endpoint == 'string'
|
|
121
|
+
? { userinfo: safe(meta.userinfo_endpoint) }
|
|
122
|
+
: {},
|
|
123
|
+
...scope ? { scopes: scope.split(' ') } : {},
|
|
124
|
+
resource: url,
|
|
125
|
+
...'authorization_response_iss_parameter_supported' in meta &&
|
|
126
|
+
meta.authorization_response_iss_parameter_supported
|
|
127
|
+
? { issuer: meta.issuer }
|
|
128
|
+
: {},
|
|
129
|
+
hosts: [new URL(url).hostname],
|
|
130
|
+
},
|
|
131
|
+
register: async (redirect) =>
|
|
132
|
+
document && meta.client_id_metadata_document_supported
|
|
133
|
+
? safe(document)
|
|
134
|
+
: (await registerClient(info.authorizationServerUrl, {
|
|
135
|
+
metadata: meta,
|
|
136
|
+
clientMetadata: client(undefined, redirect),
|
|
137
|
+
fetchFn,
|
|
138
|
+
})).client_id,
|
|
139
|
+
}
|
|
140
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yaks/mcp-client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.36",
|
|
4
|
+
"homepage": "https://jsr.io/@yaks/mcp-client",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./_dist/mod.d.ts",
|
|
9
|
+
"default": "./mod.js"
|
|
10
|
+
},
|
|
11
|
+
"./oauth": {
|
|
12
|
+
"types": "./_dist/oauth.d.ts",
|
|
13
|
+
"default": "./oauth.js"
|
|
14
|
+
},
|
|
15
|
+
"./servers": {
|
|
16
|
+
"types": "./_dist/servers.d.ts",
|
|
17
|
+
"default": "./servers.js"
|
|
18
|
+
},
|
|
19
|
+
"./vocab": {
|
|
20
|
+
"types": "./_dist/vocab.d.ts",
|
|
21
|
+
"default": "./vocab.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@yaks/graph": "0.2.36",
|
|
27
|
+
"@yaks/vocab": "0.2.36",
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.29.0"
|
|
29
|
+
},
|
|
30
|
+
"description": "Consume remote MCP tools as portable graph Tool definitions over Streamable HTTP.",
|
|
31
|
+
"repository": "https://github.com/yak-sh/yak.git"
|
|
32
|
+
}
|
package/servers.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** Persisted MCP server definitions. Connections and credentials are not graph data. */ import { MACHINE, nameOf, namespaceOf } from "./mod.js";
|
|
2
|
+
// Headers the transport, the protocol or the browser own, which a credential
|
|
3
|
+
// never replaces.
|
|
4
|
+
const OWNED = new Set([
|
|
5
|
+
'accept',
|
|
6
|
+
'connection',
|
|
7
|
+
'content-length',
|
|
8
|
+
'content-type',
|
|
9
|
+
'cookie',
|
|
10
|
+
'host',
|
|
11
|
+
'last-event-id',
|
|
12
|
+
'mcp-protocol-version',
|
|
13
|
+
'mcp-session-id',
|
|
14
|
+
'origin',
|
|
15
|
+
'transfer-encoding'
|
|
16
|
+
]);
|
|
17
|
+
/** Whether a credential may be sent in the header `name`. */ export const credentialHeader = (name)=>/^[A-Za-z0-9-]+$/.test(name) && !OWNED.has(name.toLowerCase());
|
|
18
|
+
/** Validate one definition before connecting. Invalid rows need not block other servers. */ export const serverOf = (row)=>{
|
|
19
|
+
const c = row.mcp_server;
|
|
20
|
+
if (!c || c.enabled === false) return undefined;
|
|
21
|
+
if (typeof c.url !== 'string' || typeof c.name !== 'string' || !c.name.trim()) {
|
|
22
|
+
throw new Error('MCP server requires a name and URL');
|
|
23
|
+
}
|
|
24
|
+
const machine = c.machine == null ? undefined : String(c.machine);
|
|
25
|
+
let url;
|
|
26
|
+
try {
|
|
27
|
+
url = machine ? new URL(c.url, MACHINE) : new URL(c.url);
|
|
28
|
+
} catch {
|
|
29
|
+
throw new Error('Invalid MCP URL');
|
|
30
|
+
}
|
|
31
|
+
if (machine && (!c.url.startsWith('/') || url.origin !== MACHINE)) {
|
|
32
|
+
throw new Error('An MCP server on a machine needs its path there, such as /mcp');
|
|
33
|
+
}
|
|
34
|
+
if (![
|
|
35
|
+
'http:',
|
|
36
|
+
'https:'
|
|
37
|
+
].includes(url.protocol) || url.username || url.password) {
|
|
38
|
+
throw new Error('MCP URL must be HTTP(S) without embedded credentials');
|
|
39
|
+
}
|
|
40
|
+
let allow;
|
|
41
|
+
if (c.allow != null) {
|
|
42
|
+
const value = JSON.parse(String(c.allow));
|
|
43
|
+
if (!Array.isArray(value) || value.some((v)=>typeof v !== 'string')) {
|
|
44
|
+
throw new Error('MCP allow must be a JSON array of tool names');
|
|
45
|
+
}
|
|
46
|
+
allow = value;
|
|
47
|
+
}
|
|
48
|
+
const header = c.header == null ? undefined : String(c.header);
|
|
49
|
+
if (header !== undefined && !credentialHeader(header)) {
|
|
50
|
+
throw new Error('MCP header must be a header name a credential may go in, such as X-API-Key');
|
|
51
|
+
}
|
|
52
|
+
const oauth = Object.fromEntries([
|
|
53
|
+
[
|
|
54
|
+
'redirectUrl',
|
|
55
|
+
c.redirect_url
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
'clientId',
|
|
59
|
+
c.client_id
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
'clientMetadataUrl',
|
|
63
|
+
c.client_metadata_url
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
'scope',
|
|
67
|
+
c.scope
|
|
68
|
+
]
|
|
69
|
+
].filter(([, v])=>v != null));
|
|
70
|
+
return {
|
|
71
|
+
id: row.entity.eid,
|
|
72
|
+
label: c.name,
|
|
73
|
+
server: {
|
|
74
|
+
name: row.entity.eid,
|
|
75
|
+
label: c.name,
|
|
76
|
+
namespace: namespaceOf(c.name),
|
|
77
|
+
url: url.href,
|
|
78
|
+
...machine ? {
|
|
79
|
+
machine
|
|
80
|
+
} : {},
|
|
81
|
+
...allow ? {
|
|
82
|
+
allow
|
|
83
|
+
} : {},
|
|
84
|
+
...header ? {
|
|
85
|
+
header
|
|
86
|
+
} : {},
|
|
87
|
+
...Object.keys(oauth).length ? {
|
|
88
|
+
oauth
|
|
89
|
+
} : {}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/** Public names are readable; identity and connection revisions are separate. */ export const graphToolName = (_id, server, remote)=>nameOf(server.namespace ?? server.name, remote);
|
|
94
|
+
//# sourceMappingURL=servers.js.map
|
package/servers.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"servers.js","sources":["./servers.ts"],"names":[],"mappings":"AAAA,sFAAsF,GAEtF,SAAS,OAAO,EAAE,MAAM,EAAE,WAAW,mBAA+B;AAIpE,6EAA6E;AAC7E,kBAAkB;AAClB,MAAM,QAAQ,IAAI,IAAI;EACpB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACD,2DAA2D,GAC3D,OAAO,MAAM,mBAAmB,CAAC,OAC/B,kBAAkB,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,KAAK,WAAW,IAAG;AAEhE,0FAA0F,GAC1F,OAAO,MAAM,WAAW,CAAC;EACvB,MAAM,IAAI,IAAI,UAAU;EACxB,IAAI,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,OAAO;EACtC,IACE,OAAO,EAAE,GAAG,KAAK,YAAY,OAAO,EAAE,IAAI,KAAK,YAAY,CAAC,EAAE,IAAI,CAAC,IAAI,IACvE;IACA,MAAM,IAAI,MAAM;EAClB;EACA,MAAM,UAAU,EAAE,OAAO,IAAI,OAAO,YAAY,OAAO,EAAE,OAAO;EAChE,IAAI;EACJ,IAAI;IACF,MAAM,UAAU,IAAI,IAAI,EAAE,GAAG,EAAE,WAAW,IAAI,IAAI,EAAE,GAAG;EACzD,EAAE,OAAM;IACN,MAAM,IAAI,MAAM;EAClB;EACA,IAAI,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,QAAQ,IAAI,MAAM,KAAK,OAAO,GAAG;IACjE,MAAM,IAAI,MACR;EAEJ;EACA,IACE,CAAC;IAAC;IAAS;GAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,KAAK,IAAI,QAAQ,IAAI,IAAI,QAAQ,EAC3E;IACA,MAAM,IAAI,MAAM;EAClB;EACA,IAAI;EACJ,IAAI,EAAE,KAAK,IAAI,MAAM;IACnB,MAAM,QAAQ,KAAK,KAAK,CAAC,OAAO,EAAE,KAAK;IACvC,IAAI,CAAC,MAAM,OAAO,CAAC,UAAU,MAAM,IAAI,CAAC,CAAC,IAAM,OAAO,MAAM,WAAW;MACrE,MAAM,IAAI,MAAM;IAClB;IACA,QAAQ;EACV;EACA,MAAM,SAAS,EAAE,MAAM,IAAI,OAAO,YAAY,OAAO,EAAE,MAAM;EAC7D,IAAI,WAAW,aAAa,CAAC,iBAAiB,SAAS;IACrD,MAAM,IAAI,MACR;EAEJ;EACA,MAAM,QAAQ,OAAO,WAAW,CAAC;IAC/B;MAAC;MAAe,EAAE,YAAY;KAAC;IAC/B;MAAC;MAAY,EAAE,SAAS;KAAC;IACzB;MAAC;MAAqB,EAAE,mBAAmB;KAAC;IAC5C;MAAC;MAAS,EAAE,KAAK;KAAC;GACnB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAK,KAAK;EACzB,OAAO;IACL,IAAI,IAAI,MAAM,CAAC,GAAG;IAClB,OAAO,EAAE,IAAI;IACb,QAAQ;MACN,MAAM,IAAI,MAAM,CAAC,GAAG;MACpB,OAAO,EAAE,IAAI;MACb,WAAW,YAAY,EAAE,IAAI;MAC7B,KAAK,IAAI,IAAI;MACb,GAAG,UAAU;QAAE;MAAQ,IAAI,CAAC,CAAC;MAC7B,GAAG,QAAQ;QAAE;MAAM,IAAI,CAAC,CAAC;MACzB,GAAG,SAAS;QAAE;MAAO,IAAI,CAAC,CAAC;MAC3B,GAAG,OAAO,IAAI,CAAC,OAAQ,MAAM,GAAG;QAAE;MAAM,IAAI,CAAC,CAAC;IAChD;EACF;AACF,EAAC;AAED,+EAA+E,GAC/E,OAAO,MAAM,gBAAgB,CAC3B,KACA,QACA,SACW,OAAO,OAAO,SAAS,IAAI,OAAO,IAAI,EAAE,QAAO"}
|
package/servers.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** Persisted MCP server definitions. Connections and credentials are not graph data. */
|
|
2
|
+
import type { Bundle, Comp } from 'jsr:@yaks/graph@0.2.36'
|
|
3
|
+
import { MACHINE, nameOf, namespaceOf, type Server } from './mod.js'
|
|
4
|
+
|
|
5
|
+
export type GraphServer = { id: string; label: string; server: Server }
|
|
6
|
+
|
|
7
|
+
// Headers the transport, the protocol or the browser own, which a credential
|
|
8
|
+
// never replaces.
|
|
9
|
+
const OWNED = new Set([
|
|
10
|
+
'accept',
|
|
11
|
+
'connection',
|
|
12
|
+
'content-length',
|
|
13
|
+
'content-type',
|
|
14
|
+
'cookie',
|
|
15
|
+
'host',
|
|
16
|
+
'last-event-id',
|
|
17
|
+
'mcp-protocol-version',
|
|
18
|
+
'mcp-session-id',
|
|
19
|
+
'origin',
|
|
20
|
+
'transfer-encoding',
|
|
21
|
+
])
|
|
22
|
+
/** Whether a credential may be sent in the header `name`. */
|
|
23
|
+
export const credentialHeader = (name: string): boolean =>
|
|
24
|
+
/^[A-Za-z0-9-]+$/.test(name) && !OWNED.has(name.toLowerCase())
|
|
25
|
+
|
|
26
|
+
/** Validate one definition before connecting. Invalid rows need not block other servers. */
|
|
27
|
+
export const serverOf = (row: Bundle): GraphServer | undefined => {
|
|
28
|
+
const c = row.mcp_server as Comp | undefined
|
|
29
|
+
if (!c || c.enabled === false) return undefined
|
|
30
|
+
if (
|
|
31
|
+
typeof c.url !== 'string' || typeof c.name !== 'string' || !c.name.trim()
|
|
32
|
+
) {
|
|
33
|
+
throw new Error('MCP server requires a name and URL')
|
|
34
|
+
}
|
|
35
|
+
const machine = c.machine == null ? undefined : String(c.machine)
|
|
36
|
+
let url: URL
|
|
37
|
+
try {
|
|
38
|
+
url = machine ? new URL(c.url, MACHINE) : new URL(c.url)
|
|
39
|
+
} catch {
|
|
40
|
+
throw new Error('Invalid MCP URL')
|
|
41
|
+
}
|
|
42
|
+
if (machine && (!c.url.startsWith('/') || url.origin !== MACHINE)) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
'An MCP server on a machine needs its path there, such as /mcp',
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
if (
|
|
48
|
+
!['http:', 'https:'].includes(url.protocol) || url.username || url.password
|
|
49
|
+
) {
|
|
50
|
+
throw new Error('MCP URL must be HTTP(S) without embedded credentials')
|
|
51
|
+
}
|
|
52
|
+
let allow: string[] | undefined
|
|
53
|
+
if (c.allow != null) {
|
|
54
|
+
const value = JSON.parse(String(c.allow))
|
|
55
|
+
if (!Array.isArray(value) || value.some((v) => typeof v !== 'string')) {
|
|
56
|
+
throw new Error('MCP allow must be a JSON array of tool names')
|
|
57
|
+
}
|
|
58
|
+
allow = value
|
|
59
|
+
}
|
|
60
|
+
const header = c.header == null ? undefined : String(c.header)
|
|
61
|
+
if (header !== undefined && !credentialHeader(header)) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
'MCP header must be a header name a credential may go in, such as X-API-Key',
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
const oauth = Object.fromEntries([
|
|
67
|
+
['redirectUrl', c.redirect_url],
|
|
68
|
+
['clientId', c.client_id],
|
|
69
|
+
['clientMetadataUrl', c.client_metadata_url],
|
|
70
|
+
['scope', c.scope],
|
|
71
|
+
].filter(([, v]) => v != null)) as Server['oauth']
|
|
72
|
+
return {
|
|
73
|
+
id: row.entity.eid,
|
|
74
|
+
label: c.name,
|
|
75
|
+
server: {
|
|
76
|
+
name: row.entity.eid,
|
|
77
|
+
label: c.name,
|
|
78
|
+
namespace: namespaceOf(c.name),
|
|
79
|
+
url: url.href,
|
|
80
|
+
...machine ? { machine } : {},
|
|
81
|
+
...allow ? { allow } : {},
|
|
82
|
+
...header ? { header } : {},
|
|
83
|
+
...Object.keys(oauth!).length ? { oauth } : {},
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Public names are readable; identity and connection revisions are separate. */
|
|
89
|
+
export const graphToolName = (
|
|
90
|
+
_id: string,
|
|
91
|
+
server: Server,
|
|
92
|
+
remote: string,
|
|
93
|
+
): string => nameOf(server.namespace ?? server.name, remote)
|
package/vocab.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// The component declaration, and nothing else: the module a server or a browser
|
|
2
|
+
// page imports at `@yaks/mcp-client/vocab`. It reaches no storage, no SQL and
|
|
3
|
+
// no runtime, so a browser tab loading this vocabulary loads nothing else.
|
|
4
|
+
import doc from './vocab.json' with {
|
|
5
|
+
type: 'json'
|
|
6
|
+
};
|
|
7
|
+
import manifest from './package.json' with {
|
|
8
|
+
type: 'json'
|
|
9
|
+
};
|
|
10
|
+
/** The `mcp_server` component: a server definition, persisted. */ export let mcpDoc = doc;
|
|
11
|
+
/** What this package is: its manifest's description, the one place it is
|
|
12
|
+
* written, which a host stamps on each document here. */ export let description = manifest.description;
|
|
13
|
+
/** Every document this plugin declares. */ export let docs = [
|
|
14
|
+
mcpDoc
|
|
15
|
+
];
|
|
16
|
+
//# sourceMappingURL=vocab.js.map
|
package/vocab.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocab.js","sources":["./vocab.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,8EAA8E;AAC9E,2EAA2E;AAG3E,OAAO,SAAS,oBAAoB;EAAE,MAAM;AAAO,EAAC;AACpD,OAAO,cAAc,sBAAsB;EAAE,MAAM;AAAO,EAAC;AAE3D,gEAAgE,GAChE,OAAO,IAAI,SAAmB,IAAG;AAEjC;uDACuD,GACvD,OAAO,IAAI,cAAsB,SAAS,WAAW,CAAA;AAErD,yCAAyC,GACzC,OAAO,IAAI,OAAmB;EAAC;CAAO,CAAA"}
|
package/vocab.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "urn:uuid:cad605a6-2293-4754-8023-fe51c8a53b8d",
|
|
3
|
+
"title": "mcp-client",
|
|
4
|
+
"$defs": {
|
|
5
|
+
"mcp_server": {
|
|
6
|
+
"$id": "urn:uuid:abb7af2e-ddbf-4766-b2a5-2583db7577a4",
|
|
7
|
+
"component": true,
|
|
8
|
+
"type": "object",
|
|
9
|
+
"description": "A shared remote MCP server. Entity identity and tool display names are separate.",
|
|
10
|
+
"properties": {
|
|
11
|
+
"owner": {
|
|
12
|
+
"$id": "urn:uuid:d88b5d93-0059-4250-942c-4ec52ff6b5de",
|
|
13
|
+
"type": "string",
|
|
14
|
+
"ref": "entity",
|
|
15
|
+
"death": "cascade",
|
|
16
|
+
"description": "The person who configured this server; hosted discovery and calls use only their own definition and credentials."
|
|
17
|
+
},
|
|
18
|
+
"space": {
|
|
19
|
+
"$id": "urn:uuid:bf8264b6-878b-4ac3-ad56-48d077b5b2df",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"ref": "entity",
|
|
22
|
+
"death": "cascade",
|
|
23
|
+
"description": "The space this server is connected in: that space's Operator and connections page reach it, for its owner. Absent on a server connected before servers had a space, which reaches its owner in every space and at their own connector."
|
|
24
|
+
},
|
|
25
|
+
"everyone": {
|
|
26
|
+
"$id": "urn:uuid:f6d730e6-1771-4004-9e3e-afb165c0981d",
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"description": "True serves everyone its space's Operator works with, each call carrying the credential of the person who connected it; absent or false serves that person alone."
|
|
29
|
+
},
|
|
30
|
+
"name": {
|
|
31
|
+
"$id": "urn:uuid:510571db-e723-49ec-96a3-1298a7c373e7",
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "Display name; normalized into a readable local tool namespace."
|
|
34
|
+
},
|
|
35
|
+
"url": {
|
|
36
|
+
"$id": "urn:uuid:204cb30c-413e-4b0d-9276-1d4912b58902",
|
|
37
|
+
"type": "string",
|
|
38
|
+
"description": "Streamable HTTP endpoint without embedded credentials; with `machine`, its path on that machine's own server."
|
|
39
|
+
},
|
|
40
|
+
"machine": {
|
|
41
|
+
"$id": "urn:uuid:efd22818-77cb-42f9-8c39-d90ab63f49ba",
|
|
42
|
+
"type": "string",
|
|
43
|
+
"ref": "entity",
|
|
44
|
+
"death": "cascade",
|
|
45
|
+
"description": "The entity whose tunnel (`tunnel{id, service, adopted}`) reaches the machine this server runs on, a space on a hosting platform. The server is then asked through that tunnel with no sign-in, and only for the tunnel's owner; absent for a server on the public internet."
|
|
46
|
+
},
|
|
47
|
+
"enabled": {
|
|
48
|
+
"$id": "urn:uuid:bc7537a6-45e5-4c73-9648-3d4eedbfadda",
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"description": "False disables discovery; omission enables it."
|
|
51
|
+
},
|
|
52
|
+
"allow": {
|
|
53
|
+
"$id": "urn:uuid:aa743aaf-9d34-47f4-8665-d7b4c1447098",
|
|
54
|
+
"type": "string",
|
|
55
|
+
"description": "Optional JSON array of exact remote tool names; [] exposes none."
|
|
56
|
+
},
|
|
57
|
+
"header": {
|
|
58
|
+
"$id": "urn:uuid:044ec735-2081-45ae-b1a6-6f68b51dc8a6",
|
|
59
|
+
"type": "string",
|
|
60
|
+
"description": "The request header the server's credential is sent in, such as X-API-Key, for a server that takes a key; absent sends it as `Authorization: Bearer`. The credential is the person's connection to the integration `mcp:<eid>`."
|
|
61
|
+
},
|
|
62
|
+
"redirect_url": {
|
|
63
|
+
"$id": "urn:uuid:82af4773-e67c-4780-ab29-8e9b9b967e18",
|
|
64
|
+
"type": "string"
|
|
65
|
+
},
|
|
66
|
+
"client_id": {
|
|
67
|
+
"$id": "urn:uuid:66255a0a-359c-4d01-812a-03f66dbb1068",
|
|
68
|
+
"type": "string"
|
|
69
|
+
},
|
|
70
|
+
"client_metadata_url": {
|
|
71
|
+
"$id": "urn:uuid:5f37f7dd-0aea-4abf-83cd-5a86ac819c0a",
|
|
72
|
+
"type": "string"
|
|
73
|
+
},
|
|
74
|
+
"scope": {
|
|
75
|
+
"$id": "urn:uuid:36ff3d60-2764-483e-932e-860a4af9d88b",
|
|
76
|
+
"type": "string"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
package/vocab.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// The component declaration, and nothing else: the module a server or a browser
|
|
2
|
+
// page imports at `@yaks/mcp-client/vocab`. It reaches no storage, no SQL and
|
|
3
|
+
// no runtime, so a browser tab loading this vocabulary loads nothing else.
|
|
4
|
+
|
|
5
|
+
import type { VocabDoc } from 'jsr:@yaks/vocab@0.2.36'
|
|
6
|
+
import doc from './vocab.json' with { type: 'json' }
|
|
7
|
+
import manifest from './package.json' with { type: 'json' }
|
|
8
|
+
|
|
9
|
+
/** The `mcp_server` component: a server definition, persisted. */
|
|
10
|
+
export let mcpDoc: VocabDoc = doc
|
|
11
|
+
|
|
12
|
+
/** What this package is: its manifest's description, the one place it is
|
|
13
|
+
* written, which a host stamps on each document here. */
|
|
14
|
+
export let description: string = manifest.description
|
|
15
|
+
|
|
16
|
+
/** Every document this plugin declares. */
|
|
17
|
+
export let docs: VocabDoc[] = [mcpDoc]
|