Skip to content

Commit f9e189f

Browse files
Merge pull request #16 from Linked-API/feat/network-tools
Add network sync tools: sync_network, get_network
2 parents d12f098 + 4e9c639 commit f9e189f

5 files changed

Lines changed: 91 additions & 8 deletions

File tree

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@linkedapi/mcp",
3-
"version": "2.2.1",
3+
"version": "2.3.0",
44
"description": "MCP server that lets AI assistants control LinkedIn accounts and retrieve real-time data.",
55
"main": "dist/index.js",
66
"bin": {
@@ -30,7 +30,7 @@
3030
"author": "Linked API",
3131
"license": "MIT",
3232
"dependencies": {
33-
"@linkedapi/node": "^2.2.1",
33+
"@linkedapi/node": "^2.3.0",
3434
"@modelcontextprotocol/sdk": "^1.17.4",
3535
"zod": "^4.1.1"
3636
},

src/linked-api-tools.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { FetchPostTool } from './tools/fetch-post.js';
3030
import { GetApiUsageTool } from './tools/get-api-usage-stats.js';
3131
import { GetConversationTool } from './tools/get-conversation.js';
3232
import { GetInboxTool } from './tools/get-inbox.js';
33+
import { GetNetworkTool } from './tools/get-network.js';
3334
import { GetWorkflowResultTool } from './tools/get-workflow-result.js';
3435
import { IgnoreConnectionRequestTool } from './tools/ignore-connection-request.js';
3536
import { ManageConversationTool } from './tools/manage-conversation.js';
@@ -54,6 +55,7 @@ import { SearchPeopleTool } from './tools/search-people.js';
5455
import { SendConnectionRequestTool } from './tools/send-connection-request.js';
5556
import { SendMessageTool } from './tools/send-message.js';
5657
import { SyncInboxTool } from './tools/sync-inbox.js';
58+
import { SyncNetworkTool } from './tools/sync-network.js';
5759
import { WithdrawConnectionRequestTool } from './tools/withdraw-connection-request.js';
5860
import type { TLinkedApiToolResult } from './types/linked-api-tool-result.type.js';
5961
import { AdminTool } from './utils/admin-tool.js';
@@ -80,6 +82,8 @@ export class LinkedApiTools {
8082
new GetConversationTool(),
8183
new SyncInboxTool(),
8284
new GetInboxTool(),
85+
new SyncNetworkTool(),
86+
new GetNetworkTool(),
8387
new ManageConversationTool(),
8488
new CheckConnectionStatusTool(),
8589
new RetrieveConnectionsTool(),

src/tools/get-network.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import LinkedApi, {
2+
TMappedResponse,
3+
TNetworkPollRequest,
4+
TNetworkPollResult,
5+
} from '@linkedapi/node';
6+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
7+
import z from 'zod';
8+
9+
import { LinkedApiTool } from '../utils/linked-api-tool.js';
10+
11+
export class GetNetworkTool extends LinkedApiTool<TNetworkPollRequest, TNetworkPollResult> {
12+
public readonly name = 'get_network';
13+
protected readonly schema = z.object({
14+
since: z.string().optional(),
15+
type: z.enum(['connectionAccepted', 'connectionAdded', 'connectionRequestReceived']).optional(),
16+
});
17+
18+
public override async execute({
19+
linkedapi,
20+
args: { since, type },
21+
}: {
22+
linkedapi: LinkedApi;
23+
args: TNetworkPollRequest;
24+
}): Promise<TMappedResponse<TNetworkPollResult>> {
25+
return linkedapi.pollNetwork({
26+
since,
27+
type,
28+
});
29+
}
30+
31+
public override getTool(): Tool {
32+
return {
33+
name: this.name,
34+
description:
35+
'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).',
36+
inputSchema: {
37+
type: 'object',
38+
properties: {
39+
since: {
40+
type: 'string',
41+
description:
42+
"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.",
43+
},
44+
type: {
45+
type: 'string',
46+
enum: ['connectionAccepted', 'connectionAdded', 'connectionRequestReceived'],
47+
description:
48+
'Optional event type filter: "connectionAccepted", "connectionAdded", or "connectionRequestReceived". If omitted, all event types are returned.',
49+
},
50+
},
51+
required: [],
52+
},
53+
};
54+
}
55+
}

src/tools/sync-network.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { OPERATION_NAME, TSyncNetworkParams } from '@linkedapi/node';
2+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
3+
import { z } from 'zod';
4+
5+
import { OperationTool } from '../utils/linked-api-tool.js';
6+
7+
export class SyncNetworkTool extends OperationTool<TSyncNetworkParams, unknown> {
8+
public override readonly name = 'sync_network';
9+
public override readonly operationName = OPERATION_NAME.syncNetwork;
10+
protected override readonly schema = z.object({});
11+
12+
public override getTool(): Tool {
13+
return {
14+
name: this.name,
15+
description:
16+
'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.',
17+
inputSchema: {
18+
type: 'object',
19+
properties: {},
20+
required: [],
21+
},
22+
};
23+
}
24+
}

0 commit comments

Comments
 (0)