@beeper/desktop-mcp 0.1.4 → 4.1.293
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 +10 -14
- package/code-tool.d.mts +1 -1
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts +1 -1
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +40 -6
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +4 -3
- package/code-tool.mjs.map +1 -1
- package/docs-search-tool.d.mts +44 -0
- package/docs-search-tool.d.mts.map +1 -0
- package/docs-search-tool.d.ts +44 -0
- package/docs-search-tool.d.ts.map +1 -0
- package/docs-search-tool.js +43 -0
- package/docs-search-tool.js.map +1 -0
- package/docs-search-tool.mjs +39 -0
- package/docs-search-tool.mjs.map +1 -0
- package/http.d.mts +5 -1
- package/http.d.mts.map +1 -1
- package/http.d.ts +5 -1
- package/http.d.ts.map +1 -1
- package/http.js +7 -9
- package/http.js.map +1 -1
- package/http.mjs +7 -9
- package/http.mjs.map +1 -1
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/index.mjs +3 -3
- package/index.mjs.map +1 -1
- package/options.d.mts +1 -0
- package/options.d.mts.map +1 -1
- package/options.d.ts +1 -0
- package/options.d.ts.map +1 -1
- package/options.js +15 -8
- package/options.js.map +1 -1
- package/options.mjs +15 -8
- package/options.mjs.map +1 -1
- package/package.json +12 -2
- package/server.d.mts +1 -1
- package/server.d.mts.map +1 -1
- package/server.d.ts +1 -1
- package/server.d.ts.map +1 -1
- package/server.js +39 -13
- package/server.js.map +1 -1
- package/server.mjs +40 -14
- package/server.mjs.map +1 -1
- package/src/code-tool.ts +5 -3
- package/src/docs-search-tool.ts +48 -0
- package/src/http.ts +35 -23
- package/src/index.ts +3 -3
- package/src/options.ts +19 -9
- package/src/server.ts +42 -15
- package/src/tools/accounts/get-accounts.ts +3 -3
- package/src/tools/chats/archive-chat.ts +6 -6
- package/src/tools/chats/get-chat.ts +6 -7
- package/src/tools/chats/reminders/clear-chat-reminder.ts +10 -8
- package/src/tools/chats/reminders/set-chat-reminder.ts +6 -5
- package/src/tools/chats/search-chats.ts +14 -12
- package/src/tools/index.ts +6 -4
- package/src/tools/messages/list-messages.ts +51 -0
- package/src/tools/messages/search-messages.ts +15 -26
- package/src/tools/messages/send-message.ts +5 -6
- package/src/tools/{app/open-in-app.ts → top-level/focus-app.ts} +13 -8
- package/src/tools/top-level/search.ts +41 -0
- package/tools/accounts/get-accounts.js +3 -3
- package/tools/accounts/get-accounts.js.map +1 -1
- package/tools/accounts/get-accounts.mjs +3 -3
- package/tools/accounts/get-accounts.mjs.map +1 -1
- package/tools/chats/archive-chat.d.mts.map +1 -1
- package/tools/chats/archive-chat.d.ts.map +1 -1
- package/tools/chats/archive-chat.js +6 -5
- package/tools/chats/archive-chat.js.map +1 -1
- package/tools/chats/archive-chat.mjs +6 -5
- package/tools/chats/archive-chat.mjs.map +1 -1
- package/tools/chats/get-chat.d.mts.map +1 -1
- package/tools/chats/get-chat.d.ts.map +1 -1
- package/tools/chats/get-chat.js +6 -6
- package/tools/chats/get-chat.js.map +1 -1
- package/tools/chats/get-chat.mjs +6 -6
- package/tools/chats/get-chat.mjs.map +1 -1
- package/tools/chats/reminders/clear-chat-reminder.d.mts.map +1 -1
- package/tools/chats/reminders/clear-chat-reminder.d.ts.map +1 -1
- package/tools/chats/reminders/clear-chat-reminder.js +10 -7
- package/tools/chats/reminders/clear-chat-reminder.js.map +1 -1
- package/tools/chats/reminders/clear-chat-reminder.mjs +10 -7
- package/tools/chats/reminders/clear-chat-reminder.mjs.map +1 -1
- package/tools/chats/reminders/set-chat-reminder.d.mts.map +1 -1
- package/tools/chats/reminders/set-chat-reminder.d.ts.map +1 -1
- package/tools/chats/reminders/set-chat-reminder.js +6 -5
- package/tools/chats/reminders/set-chat-reminder.js.map +1 -1
- package/tools/chats/reminders/set-chat-reminder.mjs +6 -5
- package/tools/chats/reminders/set-chat-reminder.mjs.map +1 -1
- package/tools/chats/search-chats.d.mts.map +1 -1
- package/tools/chats/search-chats.d.ts.map +1 -1
- package/tools/chats/search-chats.js +13 -12
- package/tools/chats/search-chats.js.map +1 -1
- package/tools/chats/search-chats.mjs +13 -12
- package/tools/chats/search-chats.mjs.map +1 -1
- package/tools/index.d.mts.map +1 -1
- package/tools/index.d.ts.map +1 -1
- package/tools/index.js +6 -4
- package/tools/index.js.map +1 -1
- package/tools/index.mjs +6 -4
- package/tools/index.mjs.map +1 -1
- package/tools/messages/{attachments/download-attachment.d.ts → list-messages.d.mts} +1 -1
- package/tools/messages/list-messages.d.mts.map +1 -0
- package/tools/messages/{attachments/download-attachment.d.mts → list-messages.d.ts} +1 -1
- package/tools/messages/list-messages.d.ts.map +1 -0
- package/tools/messages/list-messages.js +47 -0
- package/tools/messages/list-messages.js.map +1 -0
- package/tools/messages/list-messages.mjs +43 -0
- package/tools/messages/list-messages.mjs.map +1 -0
- package/tools/messages/search-messages.d.mts.map +1 -1
- package/tools/messages/search-messages.d.ts.map +1 -1
- package/tools/messages/search-messages.js +14 -26
- package/tools/messages/search-messages.js.map +1 -1
- package/tools/messages/search-messages.mjs +14 -26
- package/tools/messages/search-messages.mjs.map +1 -1
- package/tools/messages/send-message.d.mts.map +1 -1
- package/tools/messages/send-message.d.ts.map +1 -1
- package/tools/messages/send-message.js +5 -5
- package/tools/messages/send-message.js.map +1 -1
- package/tools/messages/send-message.mjs +5 -5
- package/tools/messages/send-message.mjs.map +1 -1
- package/tools/{app/open-in-app.d.ts → top-level/focus-app.d.mts} +1 -1
- package/tools/top-level/focus-app.d.mts.map +1 -0
- package/tools/{app/open-in-app.d.mts → top-level/focus-app.d.ts} +1 -1
- package/tools/top-level/focus-app.d.ts.map +1 -0
- package/tools/{app/open-in-app.js → top-level/focus-app.js} +13 -9
- package/tools/top-level/focus-app.js.map +1 -0
- package/tools/{app/open-in-app.mjs → top-level/focus-app.mjs} +13 -9
- package/tools/top-level/focus-app.mjs.map +1 -0
- package/tools/top-level/search.d.mts +45 -0
- package/tools/top-level/search.d.mts.map +1 -0
- package/tools/top-level/search.d.ts +45 -0
- package/tools/top-level/search.d.ts.map +1 -0
- package/tools/top-level/search.js +37 -0
- package/tools/top-level/search.js.map +1 -0
- package/tools/top-level/search.mjs +33 -0
- package/tools/top-level/search.mjs.map +1 -0
- package/src/tools/messages/attachments/download-attachment.ts +0 -42
- package/tools/app/open-in-app.d.mts.map +0 -1
- package/tools/app/open-in-app.d.ts.map +0 -1
- package/tools/app/open-in-app.js.map +0 -1
- package/tools/app/open-in-app.mjs.map +0 -1
- package/tools/messages/attachments/download-attachment.d.mts.map +0 -1
- package/tools/messages/attachments/download-attachment.d.ts.map +0 -1
- package/tools/messages/attachments/download-attachment.js +0 -39
- package/tools/messages/attachments/download-attachment.js.map +0 -1
- package/tools/messages/attachments/download-attachment.mjs +0 -35
- package/tools/messages/attachments/download-attachment.mjs.map +0 -1
package/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAoDtF,sCA8FC;AAKD,kCAyBC;AAKD,wCAYC;AA9LD,oEAAoE;AACpE,sCAAsE;AACtE,iEAM4C;AAE5C,sEAAgD;AAChD,wCAMkB;AAClB,sDAA+C;AAC/C,8CAAuC;AACvC,6EAAgD;AAIhD,sCAAsC;AAA7B,oGAAA,UAAU,OAAA;AAGnB,oCAAoC;AAA3B,kGAAA,SAAS,OAAA;AAEX,MAAM,YAAY,GAAG,GAAG,EAAE,CAC/B,IAAI,kBAAS,CACX;IACE,IAAI,EAAE,wBAAwB;IAC9B,OAAO,EAAE,SAAS;CACnB,EACD;IACE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IACxC,YAAY,EACV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EACzC,oBAAkD;IAElD,MAAM,OAAO,GAAG,EAAE,GAAG,kCAAyB,EAAE,GAAG,oBAAoB,EAAE,CAAC;IAC1E,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;QAC/B,IAAI,GAAG,IAAA,0BAAiB,EAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;AAC3C,CAAC;AAEM,MAAM,OAAO,GAAG,CAAC,GAAW,EAAsB,EAAE;IACzD,IAAI,OAAQ,UAAkB,CAAC,OAAO,KAAK,WAAW,EAAE,CAAC;QACvD,OAAQ,UAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;SAAM,IAAI,OAAQ,UAAkB,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC3D,OAAQ,UAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO;AACT,CAAC,CAAC;AAPW,QAAA,OAAO,WAOlB;AAEK,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;IACpD,IAAI,QAAQ,GAAG,IAAA,eAAO,EAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,aAAa,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB"}
|
package/server.mjs
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { endpoints, query } from "./tools.mjs";
|
|
4
|
-
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, SetLevelRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import BeeperDesktop from '@beeper/desktop-api';
|
|
6
6
|
import { applyCompatibilityTransformations, defaultClientCapabilities, knownClients, parseEmbeddedJSON, } from "./compat.mjs";
|
|
7
7
|
import { dynamicTools } from "./dynamic-tools.mjs";
|
|
8
8
|
import { codeTool } from "./code-tool.mjs";
|
|
9
|
+
import docsSearchTool from "./docs-search-tool.mjs";
|
|
9
10
|
export { ClientType } from "./compat.mjs";
|
|
10
11
|
export { endpoints } from "./tools.mjs";
|
|
11
12
|
export const newMcpServer = () => new McpServer({
|
|
12
13
|
name: 'beeper_desktop_api_api',
|
|
13
|
-
version: '
|
|
14
|
+
version: '4.1.293',
|
|
14
15
|
}, {
|
|
15
16
|
capabilities: { tools: {}, logging: {} },
|
|
16
|
-
instructions: '
|
|
17
|
+
instructions: 'Access to all chats and messages across networks using Beeper Desktop. Can be used to find, get, send, and manage messages and chats.',
|
|
17
18
|
});
|
|
18
19
|
// Create server instance
|
|
19
20
|
export const server = newMcpServer();
|
|
@@ -26,7 +27,7 @@ export function initMcpServer(params) {
|
|
|
26
27
|
const mcpOptions = params.mcpOptions ?? {};
|
|
27
28
|
let providedEndpoints = null;
|
|
28
29
|
let endpointMap = null;
|
|
29
|
-
const initTools = (implementation) => {
|
|
30
|
+
const initTools = async (implementation) => {
|
|
30
31
|
if (implementation && (!mcpOptions.client || mcpOptions.client === 'infer')) {
|
|
31
32
|
mcpOptions.client =
|
|
32
33
|
implementation.name.toLowerCase().includes('claude') ? 'claude'
|
|
@@ -37,8 +38,8 @@ export function initMcpServer(params) {
|
|
|
37
38
|
...mcpOptions.capabilities,
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
|
-
providedEndpoints = selectTools(endpoints, mcpOptions);
|
|
41
|
-
endpointMap = Object.fromEntries(providedEndpoints.map((endpoint) => [endpoint.tool.name, endpoint]));
|
|
41
|
+
providedEndpoints ?? (providedEndpoints = await selectTools(endpoints, mcpOptions));
|
|
42
|
+
endpointMap ?? (endpointMap = Object.fromEntries(providedEndpoints.map((endpoint) => [endpoint.tool.name, endpoint])));
|
|
42
43
|
};
|
|
43
44
|
const logAtLevel = (level) => (message, ...rest) => {
|
|
44
45
|
void server.sendLoggingMessage({
|
|
@@ -52,7 +53,7 @@ export function initMcpServer(params) {
|
|
|
52
53
|
warn: logAtLevel('warning'),
|
|
53
54
|
error: logAtLevel('error'),
|
|
54
55
|
};
|
|
55
|
-
|
|
56
|
+
let client = new BeeperDesktop({
|
|
56
57
|
logger,
|
|
57
58
|
...params.clientOptions,
|
|
58
59
|
defaultHeaders: {
|
|
@@ -62,7 +63,7 @@ export function initMcpServer(params) {
|
|
|
62
63
|
});
|
|
63
64
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
64
65
|
if (providedEndpoints === null) {
|
|
65
|
-
initTools(server.getClientVersion());
|
|
66
|
+
await initTools(server.getClientVersion());
|
|
66
67
|
}
|
|
67
68
|
return {
|
|
68
69
|
tools: providedEndpoints.map((endpoint) => endpoint.tool),
|
|
@@ -70,7 +71,7 @@ export function initMcpServer(params) {
|
|
|
70
71
|
});
|
|
71
72
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
72
73
|
if (endpointMap === null) {
|
|
73
|
-
initTools(server.getClientVersion());
|
|
74
|
+
await initTools(server.getClientVersion());
|
|
74
75
|
}
|
|
75
76
|
const { name, arguments: args } = request.params;
|
|
76
77
|
const endpoint = endpointMap[name];
|
|
@@ -79,13 +80,35 @@ export function initMcpServer(params) {
|
|
|
79
80
|
}
|
|
80
81
|
return executeHandler(endpoint.tool, endpoint.handler, client, args, mcpOptions.capabilities);
|
|
81
82
|
});
|
|
83
|
+
server.setRequestHandler(SetLevelRequestSchema, async (request) => {
|
|
84
|
+
const { level } = request.params;
|
|
85
|
+
switch (level) {
|
|
86
|
+
case 'debug':
|
|
87
|
+
client = client.withOptions({ logLevel: 'debug' });
|
|
88
|
+
break;
|
|
89
|
+
case 'info':
|
|
90
|
+
client = client.withOptions({ logLevel: 'info' });
|
|
91
|
+
break;
|
|
92
|
+
case 'notice':
|
|
93
|
+
case 'warning':
|
|
94
|
+
client = client.withOptions({ logLevel: 'warn' });
|
|
95
|
+
break;
|
|
96
|
+
case 'error':
|
|
97
|
+
client = client.withOptions({ logLevel: 'error' });
|
|
98
|
+
break;
|
|
99
|
+
default:
|
|
100
|
+
client = client.withOptions({ logLevel: 'off' });
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
return {};
|
|
104
|
+
});
|
|
82
105
|
}
|
|
83
106
|
/**
|
|
84
107
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
85
108
|
*/
|
|
86
|
-
export function selectTools(endpoints, options) {
|
|
109
|
+
export async function selectTools(endpoints, options) {
|
|
87
110
|
const filteredEndpoints = query(options?.filters ?? [], endpoints);
|
|
88
|
-
let includedTools = filteredEndpoints;
|
|
111
|
+
let includedTools = filteredEndpoints.slice();
|
|
89
112
|
if (includedTools.length > 0) {
|
|
90
113
|
if (options?.includeDynamicTools) {
|
|
91
114
|
includedTools = dynamicTools(includedTools);
|
|
@@ -93,18 +116,21 @@ export function selectTools(endpoints, options) {
|
|
|
93
116
|
}
|
|
94
117
|
else {
|
|
95
118
|
if (options?.includeAllTools) {
|
|
96
|
-
includedTools = endpoints;
|
|
119
|
+
includedTools = endpoints.slice();
|
|
97
120
|
}
|
|
98
121
|
else if (options?.includeDynamicTools) {
|
|
99
122
|
includedTools = dynamicTools(endpoints);
|
|
100
123
|
}
|
|
101
124
|
else if (options?.includeCodeTools) {
|
|
102
|
-
includedTools = [codeTool()];
|
|
125
|
+
includedTools = [await codeTool()];
|
|
103
126
|
}
|
|
104
127
|
else {
|
|
105
|
-
includedTools = endpoints;
|
|
128
|
+
includedTools = endpoints.slice();
|
|
106
129
|
}
|
|
107
130
|
}
|
|
131
|
+
if (options?.includeDocsTools ?? true) {
|
|
132
|
+
includedTools.push(docsSearchTool);
|
|
133
|
+
}
|
|
108
134
|
const capabilities = { ...defaultClientCapabilities, ...options?.capabilities };
|
|
109
135
|
return applyCompatibilityTransformations(includedTools, capabilities);
|
|
110
136
|
}
|
package/server.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAC5D,EAAY,SAAS,EAAmB,KAAK,EAAE;OAC/C,EACL,qBAAqB,
|
|
1
|
+
{"version":3,"file":"server.mjs","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAC5D,EAAY,SAAS,EAAmB,KAAK,EAAE;OAC/C,EACL,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,GAGtB,MAAM,oCAAoC;OAEpC,aAAa,MAAM,qBAAqB;OACxC,EACL,iCAAiC,EAEjC,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,GAClB;OACM,EAAE,YAAY,EAAE;OAChB,EAAE,QAAQ,EAAE;OACZ,cAAc;OAId,EAAE,UAAU,EAAE;OAGd,EAAE,SAAS,EAAE;AAEpB,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE,CAC/B,IAAI,SAAS,CACX;IACE,IAAI,EAAE,wBAAwB;IAC9B,OAAO,EAAE,SAAS;CACnB,EACD;IACE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IACxC,YAAY,EACV,uIAAuI;CAC1I,CACF,CAAC;AAEJ,yBAAyB;AACzB,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC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IAAI,IAAI,EAAE,CAAC;QAC/B,IAAI,GAAG,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAW,EAAsB,EAAE;IACzD,IAAI,OAAQ,UAAkB,CAAC,OAAO,KAAK,WAAW,EAAE,CAAC;QACvD,OAAQ,UAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;SAAM,IAAI,OAAQ,UAAkB,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC3D,OAAQ,UAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO;AACT,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;IACpD,IAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,aAAa,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|
package/src/code-tool.ts
CHANGED
|
@@ -7,9 +7,7 @@ import { Endpoint, ContentBlock, Metadata } from './tools/types';
|
|
|
7
7
|
|
|
8
8
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
9
9
|
|
|
10
|
-
import { newDenoHTTPWorker } from '@valtown/deno-http-worker';
|
|
11
10
|
import { WorkerInput, WorkerError, WorkerSuccess } from './code-tool-types';
|
|
12
|
-
import { workerPath } from './code-tool-paths.cjs';
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* A tool that runs code against a copy of the SDK.
|
|
@@ -20,7 +18,7 @@ import { workerPath } from './code-tool-paths.cjs';
|
|
|
20
18
|
*
|
|
21
19
|
* @param endpoints - The endpoints to include in the list.
|
|
22
20
|
*/
|
|
23
|
-
export function codeTool(): Endpoint {
|
|
21
|
+
export async function codeTool(): Promise<Endpoint> {
|
|
24
22
|
const metadata: Metadata = { resource: 'all', operation: 'write', tags: [] };
|
|
25
23
|
const tool: Tool = {
|
|
26
24
|
name: 'execute',
|
|
@@ -29,6 +27,10 @@ export function codeTool(): Endpoint {
|
|
|
29
27
|
inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
|
|
30
28
|
};
|
|
31
29
|
|
|
30
|
+
// Import dynamically to avoid failing at import time in cases where the environment is not well-supported.
|
|
31
|
+
const { newDenoHTTPWorker } = await import('@valtown/deno-http-worker');
|
|
32
|
+
const { workerPath } = await import('./code-tool-paths.cjs');
|
|
33
|
+
|
|
32
34
|
const handler = async (client: BeeperDesktop, args: unknown) => {
|
|
33
35
|
const baseURLHostname = new URL(client.baseURL).hostname;
|
|
34
36
|
const { code } = args as { code: string };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { Metadata, asTextContentResult } from './tools/types';
|
|
4
|
+
|
|
5
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
+
|
|
7
|
+
export const metadata: Metadata = {
|
|
8
|
+
resource: 'all',
|
|
9
|
+
operation: 'read',
|
|
10
|
+
tags: [],
|
|
11
|
+
httpMethod: 'get',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const tool: Tool = {
|
|
15
|
+
name: 'search_docs',
|
|
16
|
+
description:
|
|
17
|
+
'Search for documentation for how to use the client to interact with the API.\nThe tool will return an array of Markdown-formatted documentation pages.',
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
query: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
description: 'The query to search for.',
|
|
24
|
+
},
|
|
25
|
+
language: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description: 'The language for the SDK to search for.',
|
|
28
|
+
enum: ['http', 'python', 'go', 'typescript', 'terraform', 'ruby', 'java', 'kotlin'],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: ['query', 'language'],
|
|
32
|
+
},
|
|
33
|
+
annotations: {
|
|
34
|
+
readOnlyHint: true,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const docsSearchURL =
|
|
39
|
+
process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/beeper-desktop-api/docs/search';
|
|
40
|
+
|
|
41
|
+
export const handler = async (_: unknown, args: Record<string, unknown> | undefined) => {
|
|
42
|
+
const body = args as any;
|
|
43
|
+
const query = new URLSearchParams(body).toString();
|
|
44
|
+
const result = await fetch(`${docsSearchURL}?${query}`);
|
|
45
|
+
return asTextContentResult(await result.json());
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default { metadata, tool, handler };
|
package/src/http.ts
CHANGED
|
@@ -7,7 +7,7 @@ import cors from 'cors';
|
|
|
7
7
|
import express from 'express';
|
|
8
8
|
import { fromError } from 'zod-validation-error/v3';
|
|
9
9
|
import { McpOptions, parseQueryOptions } from './options';
|
|
10
|
-
import { initMcpServer, newMcpServer } from './server';
|
|
10
|
+
import { ClientOptions, initMcpServer, newMcpServer } from './server';
|
|
11
11
|
import { parseAuthHeaders } from './headers';
|
|
12
12
|
|
|
13
13
|
const oauthResourceIdentifier = (req: express.Request): string => {
|
|
@@ -15,11 +15,17 @@ const oauthResourceIdentifier = (req: express.Request): string => {
|
|
|
15
15
|
return `${protocol}://${req.get('host')}/`;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const newServer = (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const newServer = ({
|
|
19
|
+
clientOptions,
|
|
20
|
+
mcpOptions: defaultMcpOptions,
|
|
21
|
+
req,
|
|
22
|
+
res,
|
|
23
|
+
}: {
|
|
24
|
+
clientOptions: ClientOptions;
|
|
25
|
+
mcpOptions: McpOptions;
|
|
26
|
+
req: express.Request;
|
|
27
|
+
res: express.Response;
|
|
28
|
+
}): McpServer | null => {
|
|
23
29
|
const server = newMcpServer();
|
|
24
30
|
|
|
25
31
|
let mcpOptions: McpOptions;
|
|
@@ -41,10 +47,8 @@ const newServer = (
|
|
|
41
47
|
initMcpServer({
|
|
42
48
|
server: server,
|
|
43
49
|
clientOptions: {
|
|
50
|
+
...clientOptions,
|
|
44
51
|
...authOptions,
|
|
45
|
-
defaultHeaders: {
|
|
46
|
-
'X-Stainless-MCP': 'true',
|
|
47
|
-
},
|
|
48
52
|
},
|
|
49
53
|
mcpOptions,
|
|
50
54
|
});
|
|
@@ -67,17 +71,19 @@ const newServer = (
|
|
|
67
71
|
return server;
|
|
68
72
|
};
|
|
69
73
|
|
|
70
|
-
const post =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
const post =
|
|
75
|
+
(options: { clientOptions: ClientOptions; mcpOptions: McpOptions }) =>
|
|
76
|
+
async (req: express.Request, res: express.Response) => {
|
|
77
|
+
const server = newServer({ ...options, req, res });
|
|
78
|
+
// If we return null, we already set the authorization error.
|
|
79
|
+
if (server === null) return;
|
|
80
|
+
const transport = new StreamableHTTPServerTransport({
|
|
81
|
+
// Stateless server
|
|
82
|
+
sessionIdGenerator: undefined,
|
|
83
|
+
});
|
|
84
|
+
await server.connect(transport);
|
|
85
|
+
await transport.handleRequest(req, res, req.body);
|
|
86
|
+
};
|
|
81
87
|
|
|
82
88
|
const get = async (req: express.Request, res: express.Response) => {
|
|
83
89
|
res.status(405).json({
|
|
@@ -109,21 +115,27 @@ const oauthMetadata = (req: express.Request, res: express.Response) => {
|
|
|
109
115
|
});
|
|
110
116
|
};
|
|
111
117
|
|
|
112
|
-
export const streamableHTTPApp = (
|
|
118
|
+
export const streamableHTTPApp = ({
|
|
119
|
+
clientOptions = {},
|
|
120
|
+
mcpOptions = {},
|
|
121
|
+
}: {
|
|
122
|
+
clientOptions?: ClientOptions;
|
|
123
|
+
mcpOptions?: McpOptions;
|
|
124
|
+
}): express.Express => {
|
|
113
125
|
const app = express();
|
|
114
126
|
app.set('query parser', 'extended');
|
|
115
127
|
app.use(express.json());
|
|
116
128
|
|
|
117
129
|
app.get('/.well-known/oauth-protected-resource', cors(), oauthMetadata);
|
|
118
130
|
app.get('/', get);
|
|
119
|
-
app.post('/', post(
|
|
131
|
+
app.post('/', post({ clientOptions, mcpOptions }));
|
|
120
132
|
app.delete('/', del);
|
|
121
133
|
|
|
122
134
|
return app;
|
|
123
135
|
};
|
|
124
136
|
|
|
125
137
|
export const launchStreamableHTTPServer = async (options: McpOptions, port: number | string | undefined) => {
|
|
126
|
-
const app = streamableHTTPApp(options);
|
|
138
|
+
const app = streamableHTTPApp({ mcpOptions: options });
|
|
127
139
|
const server = app.listen(port);
|
|
128
140
|
const address = server.address();
|
|
129
141
|
|
package/src/index.ts
CHANGED
|
@@ -14,7 +14,7 @@ async function main() {
|
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const selectedTools = selectToolsOrError(endpoints, options);
|
|
17
|
+
const selectedTools = await selectToolsOrError(endpoints, options);
|
|
18
18
|
|
|
19
19
|
console.error(
|
|
20
20
|
`MCP Server starting with ${selectedTools.length} tools:`,
|
|
@@ -47,9 +47,9 @@ function parseOptionsOrError() {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
function selectToolsOrError(endpoints: Endpoint[], options: McpOptions): Endpoint[] {
|
|
50
|
+
async function selectToolsOrError(endpoints: Endpoint[], options: McpOptions): Promise<Endpoint[]> {
|
|
51
51
|
try {
|
|
52
|
-
const includedTools = selectTools(endpoints, options);
|
|
52
|
+
const includedTools = await selectTools(endpoints, options);
|
|
53
53
|
if (includedTools.length === 0) {
|
|
54
54
|
console.error('No tools match the provided filters.');
|
|
55
55
|
process.exit(1);
|
package/src/options.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type McpOptions = {
|
|
|
17
17
|
includeDynamicTools?: boolean | undefined;
|
|
18
18
|
includeAllTools?: boolean | undefined;
|
|
19
19
|
includeCodeTools?: boolean | undefined;
|
|
20
|
+
includeDocsTools?: boolean | undefined;
|
|
20
21
|
filters?: Filter[] | undefined;
|
|
21
22
|
capabilities?: Partial<ClientCapabilities> | undefined;
|
|
22
23
|
};
|
|
@@ -55,13 +56,13 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
55
56
|
.option('tools', {
|
|
56
57
|
type: 'string',
|
|
57
58
|
array: true,
|
|
58
|
-
choices: ['dynamic', 'all', 'code'],
|
|
59
|
+
choices: ['dynamic', 'all', 'code', 'docs'],
|
|
59
60
|
description: 'Use dynamic tools or all tools',
|
|
60
61
|
})
|
|
61
62
|
.option('no-tools', {
|
|
62
63
|
type: 'string',
|
|
63
64
|
array: true,
|
|
64
|
-
choices: ['dynamic', 'all', 'code'],
|
|
65
|
+
choices: ['dynamic', 'all', 'code', 'docs'],
|
|
65
66
|
description: 'Do not use any dynamic or all tools',
|
|
66
67
|
})
|
|
67
68
|
.option('tool', {
|
|
@@ -245,13 +246,15 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
245
246
|
}
|
|
246
247
|
}
|
|
247
248
|
|
|
248
|
-
const shouldIncludeToolType = (toolType: 'dynamic' | 'all' | 'code') =>
|
|
249
|
-
|
|
249
|
+
const shouldIncludeToolType = (toolType: 'dynamic' | 'all' | 'code' | 'docs') =>
|
|
250
|
+
argv.noTools?.includes(toolType) ? false
|
|
251
|
+
: argv.tools?.includes(toolType) ? true
|
|
252
|
+
: undefined;
|
|
250
253
|
|
|
251
|
-
const explicitTools = Boolean(argv.tools || argv.noTools);
|
|
252
254
|
const includeDynamicTools = shouldIncludeToolType('dynamic');
|
|
253
255
|
const includeAllTools = shouldIncludeToolType('all');
|
|
254
256
|
const includeCodeTools = shouldIncludeToolType('code');
|
|
257
|
+
const includeDocsTools = shouldIncludeToolType('docs');
|
|
255
258
|
|
|
256
259
|
const transport = argv.transport as 'stdio' | 'http';
|
|
257
260
|
|
|
@@ -261,6 +264,7 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
261
264
|
includeDynamicTools,
|
|
262
265
|
includeAllTools,
|
|
263
266
|
includeCodeTools,
|
|
267
|
+
includeDocsTools,
|
|
264
268
|
filters,
|
|
265
269
|
capabilities: clientCapabilities,
|
|
266
270
|
list: argv.list || false,
|
|
@@ -280,8 +284,8 @@ const coerceArray = <T extends z.ZodTypeAny>(zodType: T) =>
|
|
|
280
284
|
);
|
|
281
285
|
|
|
282
286
|
const QueryOptions = z.object({
|
|
283
|
-
tools: coerceArray(z.enum(['dynamic', 'all'])).describe('Use dynamic tools or all tools'),
|
|
284
|
-
no_tools: coerceArray(z.enum(['dynamic', 'all'])).describe('Do not use dynamic tools or all tools'),
|
|
287
|
+
tools: coerceArray(z.enum(['dynamic', 'all', 'docs'])).describe('Use dynamic tools or all tools'),
|
|
288
|
+
no_tools: coerceArray(z.enum(['dynamic', 'all', 'docs'])).describe('Do not use dynamic tools or all tools'),
|
|
285
289
|
tool: coerceArray(z.string()).describe('Include tools matching the specified names'),
|
|
286
290
|
resource: coerceArray(z.string()).describe('Include tools matching the specified resources'),
|
|
287
291
|
operation: coerceArray(z.enum(['read', 'write'])).describe(
|
|
@@ -367,20 +371,26 @@ export function parseQueryOptions(defaultOptions: McpOptions, query: unknown): M
|
|
|
367
371
|
}
|
|
368
372
|
|
|
369
373
|
let dynamicTools: boolean | undefined =
|
|
370
|
-
queryOptions.no_tools &&
|
|
374
|
+
queryOptions.no_tools && queryOptions.no_tools?.includes('dynamic') ? false
|
|
371
375
|
: queryOptions.tools?.includes('dynamic') ? true
|
|
372
376
|
: defaultOptions.includeDynamicTools;
|
|
373
377
|
|
|
374
378
|
let allTools: boolean | undefined =
|
|
375
|
-
queryOptions.no_tools &&
|
|
379
|
+
queryOptions.no_tools && queryOptions.no_tools?.includes('all') ? false
|
|
376
380
|
: queryOptions.tools?.includes('all') ? true
|
|
377
381
|
: defaultOptions.includeAllTools;
|
|
378
382
|
|
|
383
|
+
let docsTools: boolean | undefined =
|
|
384
|
+
queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
|
|
385
|
+
: queryOptions.tools?.includes('docs') ? true
|
|
386
|
+
: defaultOptions.includeDocsTools;
|
|
387
|
+
|
|
379
388
|
return {
|
|
380
389
|
client: queryOptions.client ?? defaultOptions.client,
|
|
381
390
|
includeDynamicTools: dynamicTools,
|
|
382
391
|
includeAllTools: allTools,
|
|
383
392
|
includeCodeTools: undefined,
|
|
393
|
+
includeDocsTools: docsTools,
|
|
384
394
|
filters,
|
|
385
395
|
capabilities: clientCapabilities,
|
|
386
396
|
};
|
package/src/server.ts
CHANGED
|
@@ -5,8 +5,9 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
5
5
|
import { Endpoint, endpoints, HandlerFunction, query } from './tools';
|
|
6
6
|
import {
|
|
7
7
|
CallToolRequestSchema,
|
|
8
|
-
Implementation,
|
|
9
8
|
ListToolsRequestSchema,
|
|
9
|
+
SetLevelRequestSchema,
|
|
10
|
+
Implementation,
|
|
10
11
|
Tool,
|
|
11
12
|
} from '@modelcontextprotocol/sdk/types.js';
|
|
12
13
|
import { ClientOptions } from '@beeper/desktop-api';
|
|
@@ -20,6 +21,7 @@ import {
|
|
|
20
21
|
} from './compat';
|
|
21
22
|
import { dynamicTools } from './dynamic-tools';
|
|
22
23
|
import { codeTool } from './code-tool';
|
|
24
|
+
import docsSearchTool from './docs-search-tool';
|
|
23
25
|
import { McpOptions } from './options';
|
|
24
26
|
|
|
25
27
|
export { McpOptions } from './options';
|
|
@@ -32,12 +34,12 @@ export const newMcpServer = () =>
|
|
|
32
34
|
new McpServer(
|
|
33
35
|
{
|
|
34
36
|
name: 'beeper_desktop_api_api',
|
|
35
|
-
version: '
|
|
37
|
+
version: '4.1.293',
|
|
36
38
|
},
|
|
37
39
|
{
|
|
38
40
|
capabilities: { tools: {}, logging: {} },
|
|
39
41
|
instructions:
|
|
40
|
-
'
|
|
42
|
+
'Access to all chats and messages across networks using Beeper Desktop. Can be used to find, get, send, and manage messages and chats.',
|
|
41
43
|
},
|
|
42
44
|
);
|
|
43
45
|
|
|
@@ -59,7 +61,7 @@ export function initMcpServer(params: {
|
|
|
59
61
|
let providedEndpoints: Endpoint[] | null = null;
|
|
60
62
|
let endpointMap: Record<string, Endpoint> | null = null;
|
|
61
63
|
|
|
62
|
-
const initTools = (implementation?: Implementation) => {
|
|
64
|
+
const initTools = async (implementation?: Implementation) => {
|
|
63
65
|
if (implementation && (!mcpOptions.client || mcpOptions.client === 'infer')) {
|
|
64
66
|
mcpOptions.client =
|
|
65
67
|
implementation.name.toLowerCase().includes('claude') ? 'claude'
|
|
@@ -70,8 +72,8 @@ export function initMcpServer(params: {
|
|
|
70
72
|
...mcpOptions.capabilities,
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
|
-
providedEndpoints
|
|
74
|
-
endpointMap
|
|
75
|
+
providedEndpoints ??= await selectTools(endpoints, mcpOptions);
|
|
76
|
+
endpointMap ??= Object.fromEntries(providedEndpoints.map((endpoint) => [endpoint.tool.name, endpoint]));
|
|
75
77
|
};
|
|
76
78
|
|
|
77
79
|
const logAtLevel =
|
|
@@ -89,7 +91,7 @@ export function initMcpServer(params: {
|
|
|
89
91
|
error: logAtLevel('error'),
|
|
90
92
|
};
|
|
91
93
|
|
|
92
|
-
|
|
94
|
+
let client = new BeeperDesktop({
|
|
93
95
|
logger,
|
|
94
96
|
...params.clientOptions,
|
|
95
97
|
defaultHeaders: {
|
|
@@ -100,7 +102,7 @@ export function initMcpServer(params: {
|
|
|
100
102
|
|
|
101
103
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
102
104
|
if (providedEndpoints === null) {
|
|
103
|
-
initTools(server.getClientVersion());
|
|
105
|
+
await initTools(server.getClientVersion());
|
|
104
106
|
}
|
|
105
107
|
return {
|
|
106
108
|
tools: providedEndpoints!.map((endpoint) => endpoint.tool),
|
|
@@ -109,7 +111,7 @@ export function initMcpServer(params: {
|
|
|
109
111
|
|
|
110
112
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
111
113
|
if (endpointMap === null) {
|
|
112
|
-
initTools(server.getClientVersion());
|
|
114
|
+
await initTools(server.getClientVersion());
|
|
113
115
|
}
|
|
114
116
|
const { name, arguments: args } = request.params;
|
|
115
117
|
const endpoint = endpointMap![name];
|
|
@@ -119,15 +121,38 @@ export function initMcpServer(params: {
|
|
|
119
121
|
|
|
120
122
|
return executeHandler(endpoint.tool, endpoint.handler, client, args, mcpOptions.capabilities);
|
|
121
123
|
});
|
|
124
|
+
|
|
125
|
+
server.setRequestHandler(SetLevelRequestSchema, async (request) => {
|
|
126
|
+
const { level } = request.params;
|
|
127
|
+
switch (level) {
|
|
128
|
+
case 'debug':
|
|
129
|
+
client = client.withOptions({ logLevel: 'debug' });
|
|
130
|
+
break;
|
|
131
|
+
case 'info':
|
|
132
|
+
client = client.withOptions({ logLevel: 'info' });
|
|
133
|
+
break;
|
|
134
|
+
case 'notice':
|
|
135
|
+
case 'warning':
|
|
136
|
+
client = client.withOptions({ logLevel: 'warn' });
|
|
137
|
+
break;
|
|
138
|
+
case 'error':
|
|
139
|
+
client = client.withOptions({ logLevel: 'error' });
|
|
140
|
+
break;
|
|
141
|
+
default:
|
|
142
|
+
client = client.withOptions({ logLevel: 'off' });
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
return {};
|
|
146
|
+
});
|
|
122
147
|
}
|
|
123
148
|
|
|
124
149
|
/**
|
|
125
150
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
126
151
|
*/
|
|
127
|
-
export function selectTools(endpoints: Endpoint[], options?: McpOptions): Endpoint[] {
|
|
152
|
+
export async function selectTools(endpoints: Endpoint[], options?: McpOptions): Promise<Endpoint[]> {
|
|
128
153
|
const filteredEndpoints = query(options?.filters ?? [], endpoints);
|
|
129
154
|
|
|
130
|
-
let includedTools = filteredEndpoints;
|
|
155
|
+
let includedTools = filteredEndpoints.slice();
|
|
131
156
|
|
|
132
157
|
if (includedTools.length > 0) {
|
|
133
158
|
if (options?.includeDynamicTools) {
|
|
@@ -135,16 +160,18 @@ export function selectTools(endpoints: Endpoint[], options?: McpOptions): Endpoi
|
|
|
135
160
|
}
|
|
136
161
|
} else {
|
|
137
162
|
if (options?.includeAllTools) {
|
|
138
|
-
includedTools = endpoints;
|
|
163
|
+
includedTools = endpoints.slice();
|
|
139
164
|
} else if (options?.includeDynamicTools) {
|
|
140
165
|
includedTools = dynamicTools(endpoints);
|
|
141
166
|
} else if (options?.includeCodeTools) {
|
|
142
|
-
includedTools = [codeTool()];
|
|
167
|
+
includedTools = [await codeTool()];
|
|
143
168
|
} else {
|
|
144
|
-
includedTools = endpoints;
|
|
169
|
+
includedTools = endpoints.slice();
|
|
145
170
|
}
|
|
146
171
|
}
|
|
147
|
-
|
|
172
|
+
if (options?.includeDocsTools ?? true) {
|
|
173
|
+
includedTools.push(docsSearchTool);
|
|
174
|
+
}
|
|
148
175
|
const capabilities = { ...defaultClientCapabilities, ...options?.capabilities };
|
|
149
176
|
return applyCompatibilityTransformations(includedTools, capabilities);
|
|
150
177
|
}
|
|
@@ -10,13 +10,13 @@ export const metadata: Metadata = {
|
|
|
10
10
|
operation: 'read',
|
|
11
11
|
tags: ['accounts'],
|
|
12
12
|
httpMethod: 'get',
|
|
13
|
-
httpPath: '/
|
|
14
|
-
operationId: '
|
|
13
|
+
httpPath: '/v1/accounts',
|
|
14
|
+
operationId: 'getAccounts',
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export const tool: Tool = {
|
|
18
18
|
name: 'get_accounts',
|
|
19
|
-
description: 'List connected accounts on this device.
|
|
19
|
+
description: 'List connected accounts on this device.',
|
|
20
20
|
inputSchema: {
|
|
21
21
|
type: 'object',
|
|
22
22
|
properties: {},
|