@linkedapi/mcp 1.0.1 → 2.0.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/.github/workflows/merge-main.yaml +13 -13
- package/.github/workflows/pr-main.yaml +6 -6
- package/README.md +1 -1
- package/dist/index.js +0 -23
- package/dist/index.js.map +1 -1
- package/dist/linked-api-server.d.ts +3 -3
- package/dist/linked-api-server.d.ts.map +1 -1
- package/dist/linked-api-server.js +37 -55
- package/dist/linked-api-server.js.map +1 -1
- package/dist/linked-api-tools.d.ts +5 -7
- package/dist/linked-api-tools.d.ts.map +1 -1
- package/dist/linked-api-tools.js.map +1 -1
- package/dist/prompts/index.d.ts +2 -2
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +3 -1
- package/dist/prompts/index.js.map +1 -1
- package/dist/tools/get-api-usage-stats.d.ts +0 -2
- package/dist/tools/get-api-usage-stats.d.ts.map +1 -1
- package/dist/tools/get-api-usage-stats.js.map +1 -1
- package/dist/tools/get-conversation.d.ts +4 -7
- package/dist/tools/get-conversation.d.ts.map +1 -1
- package/dist/tools/get-conversation.js +7 -23
- package/dist/tools/get-conversation.js.map +1 -1
- package/dist/tools/get-workflow-result.d.ts +6 -6
- package/dist/tools/get-workflow-result.d.ts.map +1 -1
- package/dist/tools/get-workflow-result.js +37 -13
- package/dist/tools/get-workflow-result.js.map +1 -1
- package/dist/tools/nv-get-conversation.d.ts +4 -7
- package/dist/tools/nv-get-conversation.d.ts.map +1 -1
- package/dist/tools/nv-get-conversation.js +7 -23
- package/dist/tools/nv-get-conversation.js.map +1 -1
- package/dist/types/linked-api-tool-result.type.d.ts +6 -0
- package/dist/types/linked-api-tool-result.type.d.ts.map +1 -0
- package/dist/types/linked-api-tool-result.type.js +3 -0
- package/dist/types/linked-api-tool-result.type.js.map +1 -0
- package/dist/utils/handle-linked-api-error.d.ts.map +1 -1
- package/dist/utils/handle-linked-api-error.js +0 -19
- package/dist/utils/handle-linked-api-error.js.map +1 -1
- package/dist/utils/linked-api-tool.d.ts +5 -7
- package/dist/utils/linked-api-tool.d.ts.map +1 -1
- package/dist/utils/linked-api-tool.js +4 -9
- package/dist/utils/linked-api-tool.js.map +1 -1
- package/dist/utils/types.d.ts +0 -6
- package/dist/utils/types.d.ts.map +1 -1
- package/package.json +2 -5
- package/src/index.ts +0 -29
- package/src/linked-api-server.ts +44 -66
- package/src/linked-api-tools.ts +5 -13
- package/src/prompts/index.ts +3 -1
- package/src/tools/get-api-usage-stats.ts +0 -2
- package/src/tools/get-conversation.ts +9 -30
- package/src/tools/get-workflow-result.ts +63 -24
- package/src/tools/nv-get-conversation.ts +9 -30
- package/src/types/linked-api-tool-result.type.ts +12 -0
- package/src/utils/handle-linked-api-error.ts +1 -20
- package/src/utils/linked-api-tool.ts +11 -25
- package/src/utils/types.ts +0 -6
- package/dist/utils/execute-with-progress.d.ts +0 -13
- package/dist/utils/execute-with-progress.d.ts.map +0 -1
- package/dist/utils/execute-with-progress.js +0 -85
- package/dist/utils/execute-with-progress.js.map +0 -1
- package/src/utils/execute-with-progress.ts +0 -111
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.GetConversationTool = void 0;
|
|
7
7
|
const node_1 = require("@linkedapi/node");
|
|
8
8
|
const zod_1 = __importDefault(require("zod"));
|
|
9
|
-
const execute_with_progress_js_1 = require("../utils/execute-with-progress.js");
|
|
10
9
|
const linked_api_tool_js_1 = require("../utils/linked-api-tool.js");
|
|
11
10
|
class GetConversationTool extends linked_api_tool_js_1.LinkedApiTool {
|
|
12
11
|
name = 'get_conversation';
|
|
@@ -14,31 +13,16 @@ class GetConversationTool extends linked_api_tool_js_1.LinkedApiTool {
|
|
|
14
13
|
personUrl: zod_1.default.string(),
|
|
15
14
|
since: zod_1.default.string().optional(),
|
|
16
15
|
});
|
|
17
|
-
async execute({ linkedapi, args: { personUrl, since },
|
|
18
|
-
const conversations = await this.
|
|
16
|
+
async execute({ linkedapi, args: { personUrl, since }, }) {
|
|
17
|
+
const conversations = await this.pollConversation(linkedapi, personUrl, since);
|
|
19
18
|
if (conversations.errors.length === 0) {
|
|
20
19
|
return conversations;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
operation: linkedapi.syncConversation,
|
|
26
|
-
workflowTimeout,
|
|
27
|
-
params: { personUrl },
|
|
28
|
-
progressToken,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
if (error instanceof node_1.LinkedApiWorkflowTimeoutError) {
|
|
33
|
-
error.message = `${error.message}
|
|
34
|
-
|
|
35
|
-
After get_workflow_result completes this sync workflow, call get_conversation again with the same personUrl to read the synchronized messages.`;
|
|
36
|
-
}
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
return await this.getConversation(linkedapi, personUrl, since);
|
|
21
|
+
const ack = await linkedapi.syncConversation.execute({ personUrl });
|
|
22
|
+
return { ...ack,
|
|
23
|
+
operationName: node_1.OPERATION_NAME.syncConversation };
|
|
40
24
|
}
|
|
41
|
-
async
|
|
25
|
+
async pollConversation(linkedapi, personUrl, since) {
|
|
42
26
|
const conversations = await linkedapi.pollConversations([
|
|
43
27
|
{
|
|
44
28
|
personUrl: personUrl,
|
|
@@ -54,7 +38,7 @@ After get_workflow_result completes this sync workflow, call get_conversation ag
|
|
|
54
38
|
getTool() {
|
|
55
39
|
return {
|
|
56
40
|
name: this.name,
|
|
57
|
-
description: '
|
|
41
|
+
description: 'Retrieve a conversation with a LinkedIn person via standard LinkedIn messaging. Returns the conversation immediately if it has already been synced. If the conversation has not been synced yet, this tool starts a syncConversation workflow and returns its ack ({status, workflowId, operationName: "syncConversation", message}); the client should call get_workflow_result with that workflowId until completion, then call get_conversation again to read the synced messages.',
|
|
58
42
|
inputSchema: {
|
|
59
43
|
type: 'object',
|
|
60
44
|
properties: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-conversation.js","sourceRoot":"","sources":["../../src/tools/get-conversation.ts"],"names":[],"mappings":";;;;;;AAAA,0CAIyB;AAEzB,8CAAoB;
|
|
1
|
+
{"version":3,"file":"get-conversation.js","sourceRoot":"","sources":["../../src/tools/get-conversation.ts"],"names":[],"mappings":";;;;;;AAAA,0CAIyB;AAEzB,8CAAoB;AAGpB,oEAA4D;AAE5D,MAAa,mBAAoB,SAAQ,kCAGxC;IACiB,IAAI,GAAG,kBAAkB,CAAC;IACvB,MAAM,GAAG,aAAC,CAAC,MAAM,CAAC;QACnC,SAAS,EAAE,aAAC,CAAC,MAAM,EAAE;QACrB,KAAK,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC7B,CAAC,CAAC;IAEa,KAAK,CAAC,OAAO,CAAC,EAC5B,SAAS,EACT,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,GAI3B;QACC,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC/E,IAAI,aAAa,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtC,OAAO,aAAa,CAAC;QACvB,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QACpE,OAAO,EAAE,GAAG,GAAG;YACnB,aAAa,EAAE,qBAAc,CAAC,gBAAgB,EAAE,CAAC;IAC/C,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAC5B,SAAoB,EACpB,SAAiB,EACjB,KAAc;QAEd,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,iBAAiB,CAAC;YACtD;gBACE,SAAS,EAAE,SAAS;gBACpB,IAAI,EAAE,IAAI;gBACV,KAAK,EAAE,KAAK;aACb;SACF,CAAC,CAAC;QACH,OAAO;YACL,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;YAC5D,MAAM,EAAE,aAAa,CAAC,MAAM;SAC7B,CAAC;IACJ,CAAC;IAEe,OAAO;QACrB,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EACT,udAAud;YACzd,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,SAAS,EAAE;wBACT,IAAI,EAAE,QAAQ;wBACd,WAAW,EACT,mHAAmH;qBACtH;oBACD,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,WAAW,EACT,0KAA0K;qBAC7K;iBACF;gBACD,QAAQ,EAAE,CAAC,WAAW,CAAC;aACxB;SACF,CAAC;IACJ,CAAC;CACF;AAnED,kDAmEC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import LinkedApi, { TMappedResponse } from '@linkedapi/node';
|
|
2
2
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
import z from 'zod';
|
|
4
|
+
import type { TWorkflowAck } from '../types/linked-api-tool-result.type.js';
|
|
4
5
|
import { LinkedApiTool } from '../utils/linked-api-tool.js';
|
|
5
|
-
import { LinkedApiProgressNotification } from '../utils/types.js';
|
|
6
6
|
interface IGetWorkflowResultParams {
|
|
7
7
|
workflowId: string;
|
|
8
8
|
operationName: string;
|
|
9
|
+
waitSeconds?: number;
|
|
9
10
|
}
|
|
10
11
|
export declare class GetWorkflowResultTool extends LinkedApiTool<IGetWorkflowResultParams, unknown> {
|
|
11
12
|
readonly name = "get_workflow_result";
|
|
@@ -38,14 +39,13 @@ export declare class GetWorkflowResultTool extends LinkedApiTool<IGetWorkflowRes
|
|
|
38
39
|
nvFetchCompany: "nvFetchCompany";
|
|
39
40
|
nvFetchPerson: "nvFetchPerson";
|
|
40
41
|
}>;
|
|
42
|
+
waitSeconds: z.ZodOptional<z.ZodNumber>;
|
|
41
43
|
}, z.core.$strip>;
|
|
42
|
-
execute({ linkedapi, args: { workflowId, operationName
|
|
44
|
+
execute({ linkedapi, args: { workflowId, operationName, waitSeconds }, mcpClient, }: {
|
|
43
45
|
linkedapi: LinkedApi;
|
|
44
46
|
args: IGetWorkflowResultParams;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
progressCallback: (progress: LinkedApiProgressNotification) => void;
|
|
48
|
-
}): Promise<TMappedResponse<unknown>>;
|
|
47
|
+
mcpClient: string;
|
|
48
|
+
}): Promise<TMappedResponse<unknown> | TWorkflowAck>;
|
|
49
49
|
getTool(): Tool;
|
|
50
50
|
}
|
|
51
51
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-workflow-result.d.ts","sourceRoot":"","sources":["../../src/tools/get-workflow-result.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"get-workflow-result.d.ts","sourceRoot":"","sources":["../../src/tools/get-workflow-result.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAGhB,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAK5D,UAAU,wBAAwB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,qBAAsB,SAAQ,aAAa,CAAC,wBAAwB,EAAE,OAAO,CAAC;IACzF,SAAgB,IAAI,yBAAyB;IAC7C,SAAS,CAAC,QAAQ,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAItB;IAEmB,OAAO,CAAC,EAC5B,SAAS,EACT,IAAI,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,EAChD,SAAS,GACV,EAAE;QACD,SAAS,EAAE,SAAS,CAAC;QACrB,IAAI,EAAE,wBAAwB,CAAC;QAC/B,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC;IA4BpC,OAAO,IAAI,IAAI;CA2BhC"}
|
|
@@ -6,38 +6,55 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.GetWorkflowResultTool = void 0;
|
|
7
7
|
const node_1 = require("@linkedapi/node");
|
|
8
8
|
const zod_1 = __importDefault(require("zod"));
|
|
9
|
-
const
|
|
9
|
+
const define_request_timeout_js_1 = require("../utils/define-request-timeout.js");
|
|
10
10
|
const linked_api_tool_js_1 = require("../utils/linked-api-tool.js");
|
|
11
|
+
const POLL_INTERVAL_MS = 5000;
|
|
12
|
+
const REQUEST_BUDGET_BUFFER_SECONDS = 5;
|
|
11
13
|
class GetWorkflowResultTool extends linked_api_tool_js_1.LinkedApiTool {
|
|
12
14
|
name = 'get_workflow_result';
|
|
13
15
|
schema = zod_1.default.object({
|
|
14
16
|
workflowId: zod_1.default.string(),
|
|
15
17
|
operationName: zod_1.default.enum(Object.values(node_1.OPERATION_NAME)),
|
|
18
|
+
waitSeconds: zod_1.default.number().int().min(0).optional(),
|
|
16
19
|
});
|
|
17
|
-
async execute({ linkedapi, args: { workflowId, operationName
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
async execute({ linkedapi, args: { workflowId, operationName, waitSeconds }, mcpClient, }) {
|
|
21
|
+
const typedOperationName = operationName;
|
|
22
|
+
const operation = linkedapi.operations.find((operation) => operation.operationName === typedOperationName);
|
|
23
|
+
const cap = Math.max((0, define_request_timeout_js_1.defineRequestTimeoutInSeconds)(mcpClient) - REQUEST_BUDGET_BUFFER_SECONDS, 0);
|
|
24
|
+
const budgetSeconds = Math.min(waitSeconds ?? cap, cap);
|
|
25
|
+
const deadline = Date.now() + budgetSeconds * 1000;
|
|
26
|
+
while (true) {
|
|
27
|
+
const status = await operation.status(workflowId);
|
|
28
|
+
if (!isWorkflowInProgress(status)) {
|
|
29
|
+
return status;
|
|
30
|
+
}
|
|
31
|
+
const remainingMs = deadline - Date.now();
|
|
32
|
+
if (remainingMs <= 0) {
|
|
33
|
+
return { ...status,
|
|
34
|
+
workflowId,
|
|
35
|
+
operationName: typedOperationName };
|
|
36
|
+
}
|
|
37
|
+
await sleep(Math.min(POLL_INTERVAL_MS, remainingMs));
|
|
38
|
+
}
|
|
26
39
|
}
|
|
27
40
|
getTool() {
|
|
28
41
|
return {
|
|
29
42
|
name: this.name,
|
|
30
|
-
description: '
|
|
43
|
+
description: 'Check the current state of a previously started Linked API workflow. Returns the final result when the workflow has completed, otherwise returns the current in-progress snapshot ({status, workflowId, operationName, message}). The server long-polls up to waitSeconds while the workflow is still running; if the budget elapses without completion, the in-progress snapshot is returned and the client should call this tool again with the same workflowId and operationName.',
|
|
31
44
|
inputSchema: {
|
|
32
45
|
type: 'object',
|
|
33
46
|
properties: {
|
|
34
47
|
workflowId: {
|
|
35
48
|
type: 'string',
|
|
36
|
-
description: 'Required. The workflow ID
|
|
49
|
+
description: 'Required. The workflow ID returned by the original Linked API tool call.',
|
|
37
50
|
},
|
|
38
51
|
operationName: {
|
|
39
52
|
type: 'string',
|
|
40
|
-
description: 'Required. The operationName
|
|
53
|
+
description: 'Required. The operationName returned by the original Linked API tool call. Used to map the response to the right operation.',
|
|
54
|
+
},
|
|
55
|
+
waitSeconds: {
|
|
56
|
+
type: 'number',
|
|
57
|
+
description: 'Optional. Maximum seconds the server should wait for the workflow to complete before returning the current in-progress snapshot. Defaults to the maximum the current MCP client allows; pass 0 to get an immediate one-shot snapshot.',
|
|
41
58
|
},
|
|
42
59
|
},
|
|
43
60
|
required: ['workflowId', 'operationName'],
|
|
@@ -46,4 +63,11 @@ class GetWorkflowResultTool extends linked_api_tool_js_1.LinkedApiTool {
|
|
|
46
63
|
}
|
|
47
64
|
}
|
|
48
65
|
exports.GetWorkflowResultTool = GetWorkflowResultTool;
|
|
66
|
+
function isWorkflowInProgress(result) {
|
|
67
|
+
return ('workflowStatus' in result &&
|
|
68
|
+
(result.workflowStatus === 'running' || result.workflowStatus === 'pending'));
|
|
69
|
+
}
|
|
70
|
+
function sleep(ms) {
|
|
71
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
72
|
+
}
|
|
49
73
|
//# sourceMappingURL=get-workflow-result.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-workflow-result.js","sourceRoot":"","sources":["../../src/tools/get-workflow-result.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"get-workflow-result.js","sourceRoot":"","sources":["../../src/tools/get-workflow-result.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import LinkedApi, { TConversationPollResult, TMappedResponse } from '@linkedapi/node';
|
|
2
2
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
import z from 'zod';
|
|
4
|
+
import type { TWorkflowAck } from '../types/linked-api-tool-result.type.js';
|
|
4
5
|
import { LinkedApiTool } from '../utils/linked-api-tool.js';
|
|
5
|
-
import { LinkedApiProgressNotification } from '../utils/types.js';
|
|
6
6
|
export declare class NvGetConversationTool extends LinkedApiTool<{
|
|
7
7
|
personUrl: string;
|
|
8
8
|
since?: string;
|
|
@@ -12,17 +12,14 @@ export declare class NvGetConversationTool extends LinkedApiTool<{
|
|
|
12
12
|
personUrl: z.ZodString;
|
|
13
13
|
since: z.ZodOptional<z.ZodString>;
|
|
14
14
|
}, z.core.$strip>;
|
|
15
|
-
execute({ linkedapi, args: { personUrl, since },
|
|
15
|
+
execute({ linkedapi, args: { personUrl, since }, }: {
|
|
16
16
|
linkedapi: LinkedApi;
|
|
17
17
|
args: {
|
|
18
18
|
personUrl: string;
|
|
19
19
|
since?: string;
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
progressCallback: (progress: LinkedApiProgressNotification) => void;
|
|
24
|
-
}): Promise<TMappedResponse<TConversationPollResult>>;
|
|
25
|
-
private getConversation;
|
|
21
|
+
}): Promise<TMappedResponse<TConversationPollResult> | TWorkflowAck>;
|
|
22
|
+
private pollConversation;
|
|
26
23
|
getTool(): Tool;
|
|
27
24
|
}
|
|
28
25
|
//# sourceMappingURL=nv-get-conversation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nv-get-conversation.d.ts","sourceRoot":"","sources":["../../src/tools/nv-get-conversation.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAEhB,uBAAuB,EACvB,eAAe,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,CAAC,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"nv-get-conversation.d.ts","sourceRoot":"","sources":["../../src/tools/nv-get-conversation.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAEhB,uBAAuB,EACvB,eAAe,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,qBAAa,qBAAsB,SAAQ,aAAa,CACtD;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EACrC,uBAAuB,CACxB;IACC,SAAgB,IAAI,yBAAyB;IAC7C,SAAS,CAAC,QAAQ,CAAC,MAAM;;;sBAGtB;IAEmB,OAAO,CAAC,EAC5B,SAAS,EACT,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,GAC3B,EAAE;QACD,SAAS,EAAE,SAAS,CAAC;QACrB,IAAI,EAAE;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAC7C,GAAG,OAAO,CAAC,eAAe,CAAC,uBAAuB,CAAC,GAAG,YAAY,CAAC;YAUtD,gBAAgB;IAkBd,OAAO,IAAI,IAAI;CAuBhC"}
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.NvGetConversationTool = void 0;
|
|
7
7
|
const node_1 = require("@linkedapi/node");
|
|
8
8
|
const zod_1 = __importDefault(require("zod"));
|
|
9
|
-
const execute_with_progress_js_1 = require("../utils/execute-with-progress.js");
|
|
10
9
|
const linked_api_tool_js_1 = require("../utils/linked-api-tool.js");
|
|
11
10
|
class NvGetConversationTool extends linked_api_tool_js_1.LinkedApiTool {
|
|
12
11
|
name = 'nv_get_conversation';
|
|
@@ -14,31 +13,16 @@ class NvGetConversationTool extends linked_api_tool_js_1.LinkedApiTool {
|
|
|
14
13
|
personUrl: zod_1.default.string(),
|
|
15
14
|
since: zod_1.default.string().optional(),
|
|
16
15
|
});
|
|
17
|
-
async execute({ linkedapi, args: { personUrl, since },
|
|
18
|
-
const conversations = await this.
|
|
16
|
+
async execute({ linkedapi, args: { personUrl, since }, }) {
|
|
17
|
+
const conversations = await this.pollConversation(linkedapi, personUrl, since);
|
|
19
18
|
if (conversations.errors.length === 0) {
|
|
20
19
|
return conversations;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
operation: linkedapi.nvSyncConversation,
|
|
26
|
-
workflowTimeout,
|
|
27
|
-
params: { personUrl },
|
|
28
|
-
progressToken,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
if (error instanceof node_1.LinkedApiWorkflowTimeoutError) {
|
|
33
|
-
error.message = `${error.message}
|
|
34
|
-
|
|
35
|
-
After get_workflow_result completes this sync workflow, call nv_get_conversation again with the same personUrl to read the synchronized messages.`;
|
|
36
|
-
}
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
return await this.getConversation(linkedapi, personUrl, since);
|
|
21
|
+
const ack = await linkedapi.nvSyncConversation.execute({ personUrl });
|
|
22
|
+
return { ...ack,
|
|
23
|
+
operationName: node_1.OPERATION_NAME.nvSyncConversation };
|
|
40
24
|
}
|
|
41
|
-
async
|
|
25
|
+
async pollConversation(linkedapi, personUrl, since) {
|
|
42
26
|
const conversations = await linkedapi.pollConversations([
|
|
43
27
|
{
|
|
44
28
|
personUrl: personUrl,
|
|
@@ -54,7 +38,7 @@ After get_workflow_result completes this sync workflow, call nv_get_conversation
|
|
|
54
38
|
getTool() {
|
|
55
39
|
return {
|
|
56
40
|
name: this.name,
|
|
57
|
-
description: '
|
|
41
|
+
description: 'Retrieve a conversation with a LinkedIn person via Sales Navigator messaging. Returns the conversation immediately if it has already been synced. If the conversation has not been synced yet, this tool starts an nvSyncConversation workflow and returns its ack ({status, workflowId, operationName: "nvSyncConversation", message}); the client should call get_workflow_result with that workflowId until completion, then call nv_get_conversation again to read the synced messages.',
|
|
58
42
|
inputSchema: {
|
|
59
43
|
type: 'object',
|
|
60
44
|
properties: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nv-get-conversation.js","sourceRoot":"","sources":["../../src/tools/nv-get-conversation.ts"],"names":[],"mappings":";;;;;;AAAA,0CAIyB;AAEzB,8CAAoB;
|
|
1
|
+
{"version":3,"file":"nv-get-conversation.js","sourceRoot":"","sources":["../../src/tools/nv-get-conversation.ts"],"names":[],"mappings":";;;;;;AAAA,0CAIyB;AAEzB,8CAAoB;AAGpB,oEAA4D;AAE5D,MAAa,qBAAsB,SAAQ,kCAG1C;IACiB,IAAI,GAAG,qBAAqB,CAAC;IAC1B,MAAM,GAAG,aAAC,CAAC,MAAM,CAAC;QACnC,SAAS,EAAE,aAAC,CAAC,MAAM,EAAE;QACrB,KAAK,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC7B,CAAC,CAAC;IAEa,KAAK,CAAC,OAAO,CAAC,EAC5B,SAAS,EACT,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,GAI3B;QACC,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC/E,IAAI,aAAa,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtC,OAAO,aAAa,CAAC;QACvB,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QACtE,OAAO,EAAE,GAAG,GAAG;YACnB,aAAa,EAAE,qBAAc,CAAC,kBAAkB,EAAE,CAAC;IACjD,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAC5B,SAAoB,EACpB,SAAiB,EACjB,KAAc;QAEd,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,iBAAiB,CAAC;YACtD;gBACE,SAAS,EAAE,SAAS;gBACpB,IAAI,EAAE,IAAI;gBACV,KAAK,EAAE,KAAK;aACb;SACF,CAAC,CAAC;QACH,OAAO;YACL,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;YAC5D,MAAM,EAAE,aAAa,CAAC,MAAM;SAC7B,CAAC;IACJ,CAAC;IAEe,OAAO;QACrB,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EACT,6dAA6d;YAC/d,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,SAAS,EAAE;wBACT,IAAI,EAAE,QAAQ;wBACd,WAAW,EACT,mHAAmH;qBACtH;oBACD,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,WAAW,EACT,0KAA0K;qBAC7K;iBACF;gBACD,QAAQ,EAAE,CAAC,WAAW,CAAC;aACxB;SACF,CAAC;IACJ,CAAC;CACF;AAnED,sDAmEC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TMappedResponse, TOperationName, TWorkflowInProgressResponse, TWorkflowStartedResponse } from '@linkedapi/node';
|
|
2
|
+
export type TWorkflowAck = (TWorkflowStartedResponse | TWorkflowInProgressResponse) & {
|
|
3
|
+
operationName: TOperationName;
|
|
4
|
+
};
|
|
5
|
+
export type TLinkedApiToolResult<TResult> = TWorkflowAck | TMappedResponse<TResult>;
|
|
6
|
+
//# sourceMappingURL=linked-api-tool-result.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linked-api-tool-result.type.d.ts","sourceRoot":"","sources":["../../src/types/linked-api-tool-result.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,YAAY,GAAG,CAAC,wBAAwB,GAAG,2BAA2B,CAAC,GAAG;IACpF,aAAa,EAAE,cAAc,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,OAAO,IAAI,YAAY,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linked-api-tool-result.type.js","sourceRoot":"","sources":["../../src/types/linked-api-tool-result.type.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-linked-api-error.d.ts","sourceRoot":"","sources":["../../src/utils/handle-linked-api-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"handle-linked-api-error.d.ts","sourceRoot":"","sources":["../../src/utils/handle-linked-api-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAcnF"}
|
|
@@ -1,27 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleLinkedApiError = handleLinkedApiError;
|
|
4
|
-
const node_1 = require("@linkedapi/node");
|
|
5
4
|
const prompts_1 = require("../prompts");
|
|
6
5
|
function handleLinkedApiError(error) {
|
|
7
|
-
if (error instanceof node_1.LinkedApiWorkflowTimeoutError) {
|
|
8
|
-
const { message, workflowId, operationName } = error;
|
|
9
|
-
return {
|
|
10
|
-
status: 'workflow_running',
|
|
11
|
-
message,
|
|
12
|
-
workflowId,
|
|
13
|
-
operationName,
|
|
14
|
-
nextAction: {
|
|
15
|
-
tool: 'get_workflow_result',
|
|
16
|
-
arguments: {
|
|
17
|
-
workflowId,
|
|
18
|
-
operationName,
|
|
19
|
-
},
|
|
20
|
-
repeatUntil: 'final data is returned or the tool returns Completed',
|
|
21
|
-
},
|
|
22
|
-
userMessage: 'Linked API is still working through the cloud-browser workflow. I will keep checking the existing workflow instead of starting a duplicate request.',
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
6
|
switch (error.type) {
|
|
26
7
|
case 'identificationTokenRequired':
|
|
27
8
|
case 'linkedApiTokenRequired':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-linked-api-error.js","sourceRoot":"","sources":["../../src/utils/handle-linked-api-error.ts"],"names":[],"mappings":";;AAIA,
|
|
1
|
+
{"version":3,"file":"handle-linked-api-error.js","sourceRoot":"","sources":["../../src/utils/handle-linked-api-error.ts"],"names":[],"mappings":";;AAIA,oDAcC;AAhBD,wCAAkD;AAElD,SAAgB,oBAAoB,CAAC,KAAqB;IACxD,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,6BAA6B,CAAC;QACnC,KAAK,wBAAwB,CAAC;QAC9B,KAAK,uBAAuB,CAAC;QAC7B,KAAK,4BAA4B;YAC/B,OAAO;gBACL,OAAO,EAAE,8BAAoB;aAC9B,CAAC;IACN,CAAC;IACD,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import LinkedApi, {
|
|
1
|
+
import LinkedApi, { TOperationName } from '@linkedapi/node';
|
|
2
2
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
-
import { LinkedApiProgressNotification } from 'src/utils/types';
|
|
4
3
|
import z from 'zod';
|
|
4
|
+
import type { TLinkedApiToolResult, TWorkflowAck } from '../types/linked-api-tool-result.type.js';
|
|
5
5
|
interface TLinkedApiToolExecuteOptions<TParams> {
|
|
6
6
|
linkedapi: LinkedApi;
|
|
7
7
|
args: TParams;
|
|
8
|
-
|
|
9
|
-
progressToken?: string | number;
|
|
10
|
-
progressCallback: (progress: LinkedApiProgressNotification) => void;
|
|
8
|
+
mcpClient: string;
|
|
11
9
|
}
|
|
12
10
|
export declare abstract class LinkedApiTool<TParams, TResult> {
|
|
13
11
|
abstract readonly name: string;
|
|
14
12
|
protected abstract readonly schema: z.ZodSchema;
|
|
15
13
|
abstract getTool(): Tool;
|
|
16
14
|
validate(args: unknown): TParams;
|
|
17
|
-
abstract execute(
|
|
15
|
+
abstract execute(options: TLinkedApiToolExecuteOptions<TParams>): Promise<TLinkedApiToolResult<TResult>>;
|
|
18
16
|
}
|
|
19
17
|
export declare abstract class OperationTool<TParams, TResult> extends LinkedApiTool<TParams, TResult> {
|
|
20
18
|
abstract readonly operationName: TOperationName;
|
|
21
|
-
execute({ linkedapi, args,
|
|
19
|
+
execute({ linkedapi, args, }: TLinkedApiToolExecuteOptions<TParams>): Promise<TWorkflowAck>;
|
|
22
20
|
}
|
|
23
21
|
export {};
|
|
24
22
|
//# sourceMappingURL=linked-api-tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linked-api-tool.d.ts","sourceRoot":"","sources":["../../src/utils/linked-api-tool.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAa,
|
|
1
|
+
{"version":3,"file":"linked-api-tool.d.ts","sourceRoot":"","sources":["../../src/utils/linked-api-tool.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAa,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAElG,UAAU,4BAA4B,CAAC,OAAO;IAC5C,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,8BAAsB,aAAa,CAAC,OAAO,EAAE,OAAO;IAClD,kBAAyB,IAAI,EAAE,MAAM,CAAC;IACtC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC;aAEhC,OAAO,IAAI,IAAI;IAExB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;aAIvB,OAAO,CACrB,OAAO,EAAE,4BAA4B,CAAC,OAAO,CAAC,GAC7C,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;CAC1C;AAED,8BAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,CAAE,SAAQ,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC;IAC3F,kBAAyB,aAAa,EAAE,cAAc,CAAC;IAEjC,OAAO,CAAC,EAC5B,SAAS,EACT,IAAI,GACL,EAAE,4BAA4B,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;CAQjE"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OperationTool = exports.LinkedApiTool = void 0;
|
|
4
|
-
const execute_with_progress_1 = require("./execute-with-progress");
|
|
5
4
|
class LinkedApiTool {
|
|
6
5
|
validate(args) {
|
|
7
6
|
return this.schema.parse(args);
|
|
@@ -9,15 +8,11 @@ class LinkedApiTool {
|
|
|
9
8
|
}
|
|
10
9
|
exports.LinkedApiTool = LinkedApiTool;
|
|
11
10
|
class OperationTool extends LinkedApiTool {
|
|
12
|
-
execute({ linkedapi, args,
|
|
11
|
+
async execute({ linkedapi, args, }) {
|
|
13
12
|
const operation = linkedapi.operations.find((operation) => operation.operationName === this.operationName);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
workflowTimeout,
|
|
18
|
-
params: args,
|
|
19
|
-
progressToken,
|
|
20
|
-
});
|
|
13
|
+
const response = await operation.execute(args);
|
|
14
|
+
return { ...response,
|
|
15
|
+
operationName: this.operationName };
|
|
21
16
|
}
|
|
22
17
|
}
|
|
23
18
|
exports.OperationTool = OperationTool;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linked-api-tool.js","sourceRoot":"","sources":["../../src/utils/linked-api-tool.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"linked-api-tool.js","sourceRoot":"","sources":["../../src/utils/linked-api-tool.ts"],"names":[],"mappings":";;;AAYA,MAAsB,aAAa;IAM1B,QAAQ,CAAC,IAAa;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAY,CAAC;IAC5C,CAAC;CAKF;AAbD,sCAaC;AAED,MAAsB,aAAgC,SAAQ,aAA+B;IAG3E,KAAK,CAAC,OAAO,CAAC,EAC5B,SAAS,EACT,IAAI,GACkC;QACtC,MAAM,SAAS,GAAG,SAAS,CAAC,UAAU,CAAC,IAAI,CACzC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,aAAa,KAAK,IAAI,CAAC,aAAa,CAC9B,CAAC;QAClC,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/C,OAAO,EAAE,GAAG,QAAQ;YACxB,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC;IAClC,CAAC;CACF;AAdD,sCAcC"}
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -7,10 +7,4 @@ export interface ExtendedCallToolRequest extends CallToolRequest {
|
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
export interface LinkedApiProgressNotification {
|
|
11
|
-
progressToken?: string | number;
|
|
12
|
-
progress: number;
|
|
13
|
-
total?: number;
|
|
14
|
-
message?: string;
|
|
15
|
-
}
|
|
16
10
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAErF,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG;QAClC,KAAK,CAAC,EAAE;YACN,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;SACjC,CAAC;KACH,CAAC;CACH
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAErF,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG;QAClC,KAAK,CAAC,EAAE;YACN,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;SACjC,CAAC;KACH,CAAC;CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linkedapi/mcp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "MCP server that lets AI assistants control LinkedIn accounts and retrieve real-time data.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"author": "Linked API",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@linkedapi/node": "^
|
|
33
|
+
"@linkedapi/node": "^2.0.0",
|
|
34
34
|
"@modelcontextprotocol/sdk": "^1.17.4",
|
|
35
35
|
"zod": "^4.1.1"
|
|
36
36
|
},
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"@eslint/eslintrc": "^3.3.1",
|
|
40
40
|
"@eslint/js": "^9.24.0",
|
|
41
41
|
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
|
42
|
-
"@types/jest": "^29.5.12",
|
|
43
42
|
"@types/node": "^20.12.12",
|
|
44
43
|
"@typescript-eslint/eslint-plugin": "^8.29.1",
|
|
45
44
|
"@typescript-eslint/parser": "^8.29.1",
|
|
@@ -51,9 +50,7 @@
|
|
|
51
50
|
"eslint-plugin-promise": "^7.2.1",
|
|
52
51
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
53
52
|
"husky": "^9.1.7",
|
|
54
|
-
"jest": "^29.7.0",
|
|
55
53
|
"prettier": "^3.5.3",
|
|
56
|
-
"ts-jest": "^29.1.2",
|
|
57
54
|
"ts-node": "^10.9.2",
|
|
58
55
|
"tsx": "^4.7.1",
|
|
59
56
|
"typescript": "^5.8.3",
|
package/src/index.ts
CHANGED
|
@@ -13,7 +13,6 @@ import { LinkedApiMCPServer } from './linked-api-server';
|
|
|
13
13
|
import { availablePrompts, getPromptContent, systemPrompt } from './prompts';
|
|
14
14
|
import { JsonHTTPServerTransport } from './utils/json-http-transport';
|
|
15
15
|
import { logger } from './utils/logger';
|
|
16
|
-
import { LinkedApiProgressNotification } from './utils/types';
|
|
17
16
|
|
|
18
17
|
function deriveClientFromUserAgent(userAgent: string): string {
|
|
19
18
|
const ua = userAgent.toLowerCase();
|
|
@@ -139,38 +138,10 @@ async function main() {
|
|
|
139
138
|
mcpClient = deriveClientFromUserAgent(userAgentHeader);
|
|
140
139
|
}
|
|
141
140
|
}
|
|
142
|
-
const progressCallback = (notification: LinkedApiProgressNotification): void => {
|
|
143
|
-
const { progressToken, progress, total, message } = notification;
|
|
144
|
-
if (progressToken === undefined) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
void extra
|
|
149
|
-
.sendNotification({
|
|
150
|
-
method: 'notifications/progress',
|
|
151
|
-
params: {
|
|
152
|
-
progressToken,
|
|
153
|
-
progress,
|
|
154
|
-
total,
|
|
155
|
-
message,
|
|
156
|
-
},
|
|
157
|
-
})
|
|
158
|
-
.catch((error: unknown) => {
|
|
159
|
-
logger.warn(
|
|
160
|
-
{
|
|
161
|
-
toolName: request.params.name,
|
|
162
|
-
error: error instanceof Error ? error.message : String(error),
|
|
163
|
-
},
|
|
164
|
-
'Failed to send MCP progress notification',
|
|
165
|
-
);
|
|
166
|
-
});
|
|
167
|
-
};
|
|
168
|
-
|
|
169
141
|
const result = await linkedApiServer.executeWithTokens(request.params, {
|
|
170
142
|
linkedApiToken,
|
|
171
143
|
identificationToken,
|
|
172
144
|
mcpClient,
|
|
173
|
-
progressCallback,
|
|
174
145
|
});
|
|
175
146
|
return result;
|
|
176
147
|
} catch (error) {
|