From 4e9c639a48b52783c8ff2f5e3a9192d34bab9e79 Mon Sep 17 00:00:00 2001 From: Maksim Redzkin Date: Thu, 16 Jul 2026 11:12:38 +0300 Subject: [PATCH] Add network sync tools: sync_network, get_network --- package-lock.json | 12 ++++----- package.json | 4 +-- src/linked-api-tools.ts | 4 +++ src/tools/get-network.ts | 55 +++++++++++++++++++++++++++++++++++++++ src/tools/sync-network.ts | 24 +++++++++++++++++ 5 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 src/tools/get-network.ts create mode 100644 src/tools/sync-network.ts diff --git a/package-lock.json b/package-lock.json index 60defee..836fc7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@linkedapi/mcp", - "version": "2.2.1", + "version": "2.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@linkedapi/mcp", - "version": "2.2.1", + "version": "2.3.0", "license": "MIT", "dependencies": { - "@linkedapi/node": "^2.2.1", + "@linkedapi/node": "^2.3.0", "@modelcontextprotocol/sdk": "^1.17.4", "zod": "^4.1.1" }, @@ -921,9 +921,9 @@ } }, "node_modules/@linkedapi/node": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@linkedapi/node/-/node-2.2.1.tgz", - "integrity": "sha512-4Qdcsog5S/1UxFfYAGNlb63NMh2aCg9o3+CCGfKC4XJrosDwqykhXSa/2fT7OG3UwVkSqM7s2kl/BB7sF8um5Q==" + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@linkedapi/node/-/node-2.3.0.tgz", + "integrity": "sha512-wavZKSUOGD6ze0cMw5sZ/zMJN1ll9qe1E8smP5dga2xTPj7Ei57rpkI3E884cDFMq7PewaRhGgcfkobr9Oy+SQ==" }, "node_modules/@modelcontextprotocol/sdk": { "version": "1.26.0", diff --git a/package.json b/package.json index 9bde905..a17a808 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@linkedapi/mcp", - "version": "2.2.1", + "version": "2.3.0", "description": "MCP server that lets AI assistants control LinkedIn accounts and retrieve real-time data.", "main": "dist/index.js", "bin": { @@ -30,7 +30,7 @@ "author": "Linked API", "license": "MIT", "dependencies": { - "@linkedapi/node": "^2.2.1", + "@linkedapi/node": "^2.3.0", "@modelcontextprotocol/sdk": "^1.17.4", "zod": "^4.1.1" }, diff --git a/src/linked-api-tools.ts b/src/linked-api-tools.ts index 12dea30..77d3972 100644 --- a/src/linked-api-tools.ts +++ b/src/linked-api-tools.ts @@ -30,6 +30,7 @@ import { FetchPostTool } from './tools/fetch-post.js'; import { GetApiUsageTool } from './tools/get-api-usage-stats.js'; import { GetConversationTool } from './tools/get-conversation.js'; import { GetInboxTool } from './tools/get-inbox.js'; +import { GetNetworkTool } from './tools/get-network.js'; import { GetWorkflowResultTool } from './tools/get-workflow-result.js'; import { IgnoreConnectionRequestTool } from './tools/ignore-connection-request.js'; import { ManageConversationTool } from './tools/manage-conversation.js'; @@ -54,6 +55,7 @@ import { SearchPeopleTool } from './tools/search-people.js'; import { SendConnectionRequestTool } from './tools/send-connection-request.js'; import { SendMessageTool } from './tools/send-message.js'; import { SyncInboxTool } from './tools/sync-inbox.js'; +import { SyncNetworkTool } from './tools/sync-network.js'; import { WithdrawConnectionRequestTool } from './tools/withdraw-connection-request.js'; import type { TLinkedApiToolResult } from './types/linked-api-tool-result.type.js'; import { AdminTool } from './utils/admin-tool.js'; @@ -80,6 +82,8 @@ export class LinkedApiTools { new GetConversationTool(), new SyncInboxTool(), new GetInboxTool(), + new SyncNetworkTool(), + new GetNetworkTool(), new ManageConversationTool(), new CheckConnectionStatusTool(), new RetrieveConnectionsTool(), diff --git a/src/tools/get-network.ts b/src/tools/get-network.ts new file mode 100644 index 0000000..a912721 --- /dev/null +++ b/src/tools/get-network.ts @@ -0,0 +1,55 @@ +import LinkedApi, { + TMappedResponse, + TNetworkPollRequest, + TNetworkPollResult, +} from '@linkedapi/node'; +import { Tool } from '@modelcontextprotocol/sdk/types.js'; +import z from 'zod'; + +import { LinkedApiTool } from '../utils/linked-api-tool.js'; + +export class GetNetworkTool extends LinkedApiTool { + public readonly name = 'get_network'; + protected readonly schema = z.object({ + since: z.string().optional(), + type: z.enum(['connectionAccepted', 'connectionAdded', 'connectionRequestReceived']).optional(), + }); + + public override async execute({ + linkedapi, + args: { since, type }, + }: { + linkedapi: LinkedApi; + args: TNetworkPollRequest; + }): Promise> { + return linkedapi.pollNetwork({ + since, + type, + }); + } + + public override getTool(): Tool { + return { + name: this.name, + description: + 'Get connection events from the monitored network, newest first. Requires network monitoring to be enabled once with sync_network. Event types: "connectionAccepted" (a connection request you sent was accepted), "connectionAdded" (a new connection appeared in your network), "connectionRequestReceived" (someone sent you a connection request).', + inputSchema: { + type: 'object', + properties: { + since: { + type: 'string', + description: + "Optional ISO 8601 timestamp to only retrieve events after this date (e.g., '2024-01-15T10:30:00Z'). If not provided, all captured events are returned.", + }, + type: { + type: 'string', + enum: ['connectionAccepted', 'connectionAdded', 'connectionRequestReceived'], + description: + 'Optional event type filter: "connectionAccepted", "connectionAdded", or "connectionRequestReceived". If omitted, all event types are returned.', + }, + }, + required: [], + }, + }; + } +} diff --git a/src/tools/sync-network.ts b/src/tools/sync-network.ts new file mode 100644 index 0000000..36d9f36 --- /dev/null +++ b/src/tools/sync-network.ts @@ -0,0 +1,24 @@ +import { OPERATION_NAME, TSyncNetworkParams } from '@linkedapi/node'; +import { Tool } from '@modelcontextprotocol/sdk/types.js'; +import { z } from 'zod'; + +import { OperationTool } from '../utils/linked-api-tool.js'; + +export class SyncNetworkTool extends OperationTool { + public override readonly name = 'sync_network'; + public override readonly operationName = OPERATION_NAME.syncNetwork; + protected override readonly schema = z.object({}); + + public override getTool(): Tool { + return { + name: this.name, + description: + 'Enable background network monitoring so connection events can be polled with get_network (st.syncNetwork action). Run once per account; only changes that happen after it is enabled are captured.', + inputSchema: { + type: 'object', + properties: {}, + required: [], + }, + }; + } +}