linkbreakers-mcp 1.186.2 → 1.187.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/lib/client-header.js +25 -0
- package/lib/proxy.js +14 -1
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// The Linkbreakers-Client header the bridge sends to the MCP server:
|
|
2
|
+
// mcp-bridge/<version> (node <version>; <platform>; client=<name> <version>)
|
|
3
|
+
// The client part names the MCP client on the other side of stdio, from its
|
|
4
|
+
// initialize, so the server can count the end client and not just the bridge.
|
|
5
|
+
// Nothing about the user or the machine beyond the OS family.
|
|
6
|
+
|
|
7
|
+
const PLATFORMS = { darwin: 'darwin', linux: 'linux', win32: 'windows' };
|
|
8
|
+
|
|
9
|
+
function clean(value, max) {
|
|
10
|
+
return String(value ?? '')
|
|
11
|
+
.replace(/[^A-Za-z0-9 ._+-]/g, '')
|
|
12
|
+
.trim()
|
|
13
|
+
.slice(0, max);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function clientHeader(version, endClient) {
|
|
17
|
+
const platform = PLATFORMS[process.platform] ?? 'other';
|
|
18
|
+
const details = [`node ${process.versions.node}`, platform];
|
|
19
|
+
const name = clean(endClient?.name, 40);
|
|
20
|
+
if (name) {
|
|
21
|
+
const clientVersion = clean(endClient?.version, 24).replace(/ /g, '');
|
|
22
|
+
details.push(`client=${name}${clientVersion ? ` ${clientVersion}` : ''}`);
|
|
23
|
+
}
|
|
24
|
+
return `mcp-bridge/${clean(version, 24) || 'unknown'} (${details.join('; ')})`;
|
|
25
|
+
}
|
package/lib/proxy.js
CHANGED
|
@@ -5,6 +5,7 @@ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/
|
|
|
5
5
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
6
6
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
7
7
|
import { McpError, ResultSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
+
import { clientHeader } from './client-header.js';
|
|
8
9
|
import { FileOAuthProvider, hasStoredTokens, openBrowser } from './oauth.js';
|
|
9
10
|
|
|
10
11
|
const { version } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
@@ -23,7 +24,16 @@ export async function main() {
|
|
|
23
24
|
let connecting;
|
|
24
25
|
let signIn;
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
// The transport reads these headers on every request, so updating the
|
|
28
|
+
// object once the local MCP client has introduced itself is enough.
|
|
29
|
+
const requestHeaders = { 'Linkbreakers-Client': clientHeader(version) };
|
|
30
|
+
const transportOptions = { authProvider: oauth, requestInit: { headers: requestHeaders } };
|
|
31
|
+
// Also called before forwarding a request: a client that sends its first
|
|
32
|
+
// request right behind initialize can get there before the initialized
|
|
33
|
+
// notification is handled.
|
|
34
|
+
const nameLocalClient = () => {
|
|
35
|
+
requestHeaders['Linkbreakers-Client'] = clientHeader(version, server?.getClientVersion());
|
|
36
|
+
};
|
|
27
37
|
|
|
28
38
|
async function connectRemote(transport = new StreamableHTTPClientTransport(SERVER_URL, transportOptions)) {
|
|
29
39
|
const client = new Client({ name: 'linkbreakers-mcp', version }, { capabilities: {} });
|
|
@@ -103,6 +113,7 @@ export async function main() {
|
|
|
103
113
|
);
|
|
104
114
|
|
|
105
115
|
server.fallbackRequestHandler = async (request, extra) => {
|
|
116
|
+
nameLocalClient();
|
|
106
117
|
const client = await ensureRemote();
|
|
107
118
|
const progressToken = request.params?._meta?.progressToken;
|
|
108
119
|
return client.request({ method: request.method, params: request.params }, ResultSchema, {
|
|
@@ -121,6 +132,8 @@ export async function main() {
|
|
|
121
132
|
await remote?.notification(notification).catch(() => {});
|
|
122
133
|
};
|
|
123
134
|
|
|
135
|
+
server.oninitialized = nameLocalClient;
|
|
136
|
+
|
|
124
137
|
server.onclose = async () => {
|
|
125
138
|
await remote?.close().catch(() => {});
|
|
126
139
|
process.exit(0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linkbreakers-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.187.1",
|
|
4
4
|
"mcpName": "com.linkbreakers/mcp",
|
|
5
5
|
"description": "Local stdio bridge to the Linkbreakers MCP server (https://mcp.linkbreakers.com) for MCP clients that only run local servers.",
|
|
6
6
|
"keywords": [
|