Skip to content

Commit 57cbe2a

Browse files
Add admin tools
1 parent 9955221 commit 57cbe2a

12 files changed

Lines changed: 434 additions & 2 deletions

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.1.0",
3+
"version": "2.1.1",
44
"description": "MCP server that lets AI assistants control LinkedIn accounts and retrieve real-time data.",
55
"main": "dist/index.js",
66
"bin": {
@@ -17,7 +17,7 @@
1717
"clean": "rm -rf dist",
1818
"typecheck": "tsc --noEmit",
1919
"lint": "eslint src --fix",
20-
"format": "prettier --write \"src/**/*.ts\"",
20+
"format": "prettier --write --log-level warn \"src/**/*.ts\"",
2121
"prepublishOnly": "npm run clean && npm run build",
2222
"prepare": "husky"
2323
},

src/linked-api-tools.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
import LinkedApi from '@linkedapi/node';
22
import { Tool } from '@modelcontextprotocol/sdk/types.js';
33

4+
import { AdminCancelConnectionSessionTool } from './tools/admin-cancel-connection-session.js';
5+
import { AdminCancelSubscriptionTool } from './tools/admin-cancel-subscription.js';
46
import { AdminConnectAccountTool } from './tools/admin-connect-account.js';
7+
import { AdminCreateReconnectionSessionTool } from './tools/admin-create-reconnection-session.js';
8+
import { AdminDeleteLimitsTool } from './tools/admin-delete-limits.js';
59
import { AdminDisconnectAccountTool } from './tools/admin-disconnect-account.js';
610
import { AdminGetAccountsTool } from './tools/admin-get-accounts.js';
11+
import { AdminGetBillingLinkTool } from './tools/admin-get-billing-link.js';
12+
import { AdminGetConnectionSessionTool } from './tools/admin-get-connection-session.js';
13+
import { AdminGetLimitsDefaultsTool } from './tools/admin-get-limits-defaults.js';
714
import { AdminGetLimitsUsageTool } from './tools/admin-get-limits-usage.js';
15+
import { AdminGetLimitsTool } from './tools/admin-get-limits.js';
816
import { AdminGetSeatsTool } from './tools/admin-get-seats.js';
17+
import { AdminGetSubscriptionPricingTool } from './tools/admin-get-subscription-pricing.js';
918
import { AdminGetSubscriptionStatusTool } from './tools/admin-get-subscription-status.js';
1019
import { AdminRegenerateTokenTool } from './tools/admin-regenerate-token.js';
20+
import { AdminReparseAccountInfoTool } from './tools/admin-reparse-account-info.js';
1121
import { AdminResetLimitsTool } from './tools/admin-reset-limits.js';
1222
import { AdminSetLimitsTool } from './tools/admin-set-limits.js';
1323
import { AdminSetSeatsTool } from './tools/admin-set-seats.js';
@@ -98,12 +108,22 @@ export class LinkedApiTools {
98108
new AdminGetSubscriptionStatusTool(),
99109
new AdminGetSeatsTool(),
100110
new AdminSetSeatsTool(),
111+
new AdminGetSubscriptionPricingTool(),
112+
new AdminGetBillingLinkTool(),
113+
new AdminCancelSubscriptionTool(),
101114
new AdminGetAccountsTool(),
115+
new AdminReparseAccountInfoTool(),
116+
new AdminCreateReconnectionSessionTool(),
102117
new AdminConnectAccountTool(),
118+
new AdminGetConnectionSessionTool(),
119+
new AdminCancelConnectionSessionTool(),
103120
new AdminDisconnectAccountTool(),
104121
new AdminRegenerateTokenTool(),
122+
new AdminGetLimitsDefaultsTool(),
123+
new AdminGetLimitsTool(),
105124
new AdminGetLimitsUsageTool(),
106125
new AdminSetLimitsTool(),
126+
new AdminDeleteLimitsTool(),
107127
new AdminResetLimitsTool(),
108128
];
109129
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { LinkedApiAdmin, TCancelConnectionSessionParams } from '@linkedapi/node';
2+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
3+
import z from 'zod';
4+
5+
import { AdminTool } from '../utils/admin-tool.js';
6+
7+
export class AdminCancelConnectionSessionTool extends AdminTool<
8+
TCancelConnectionSessionParams,
9+
void
10+
> {
11+
public readonly name = 'admin_cancel_connection_session';
12+
protected readonly schema = z.object({
13+
sessionId: z.string(),
14+
});
15+
16+
public override async execute({
17+
admin,
18+
args,
19+
}: {
20+
admin: LinkedApiAdmin;
21+
args: TCancelConnectionSessionParams;
22+
}): Promise<void> {
23+
await admin.accounts.cancelConnectionSession(args);
24+
}
25+
26+
public override getTool(): Tool {
27+
return {
28+
name: this.name,
29+
description: 'Cancel a pending connection or reconnection session.',
30+
inputSchema: {
31+
type: 'object',
32+
properties: {
33+
sessionId: {
34+
type: 'string',
35+
description: 'Connection session UUID',
36+
},
37+
},
38+
required: ['sessionId'],
39+
},
40+
};
41+
}
42+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { LinkedApiAdmin, TCancelResult } from '@linkedapi/node';
2+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
3+
import z from 'zod';
4+
5+
import { AdminTool } from '../utils/admin-tool.js';
6+
7+
export class AdminCancelSubscriptionTool extends AdminTool<Record<string, never>, TCancelResult> {
8+
public readonly name = 'admin_cancel_subscription';
9+
protected readonly schema = z.object({});
10+
11+
public override async execute({
12+
admin,
13+
}: {
14+
admin: LinkedApiAdmin;
15+
args: Record<string, never>;
16+
}): Promise<TCancelResult> {
17+
return await admin.subscription.cancel();
18+
}
19+
20+
public override getTool(): Tool {
21+
return {
22+
name: this.name,
23+
description: 'Cancel the current subscription at the end of the billing period.',
24+
inputSchema: {
25+
type: 'object',
26+
properties: {},
27+
},
28+
};
29+
}
30+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import {
2+
LinkedApiAdmin,
3+
TCreateReconnectionSessionParams,
4+
TCreateReconnectionSessionResult,
5+
} from '@linkedapi/node';
6+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
7+
import z from 'zod';
8+
9+
import { AdminTool } from '../utils/admin-tool.js';
10+
11+
export class AdminCreateReconnectionSessionTool extends AdminTool<
12+
TCreateReconnectionSessionParams,
13+
TCreateReconnectionSessionResult
14+
> {
15+
public readonly name = 'admin_create_reconnection_session';
16+
protected readonly schema = z.object({
17+
accountId: z.string(),
18+
});
19+
20+
public override async execute({
21+
admin,
22+
args,
23+
}: {
24+
admin: LinkedApiAdmin;
25+
args: TCreateReconnectionSessionParams;
26+
}): Promise<TCreateReconnectionSessionResult> {
27+
return await admin.accounts.createReconnectionSession(args);
28+
}
29+
30+
public override getTool(): Tool {
31+
return {
32+
name: this.name,
33+
description:
34+
'Create a reconnection session for an account with status reconnection_required. Returns reconnectionSessionId and reconnectionLink.',
35+
inputSchema: {
36+
type: 'object',
37+
properties: {
38+
accountId: {
39+
type: 'string',
40+
description: 'UUID of the account to reconnect',
41+
},
42+
},
43+
required: ['accountId'],
44+
},
45+
};
46+
}
47+
}

src/tools/admin-delete-limits.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { LinkedApiAdmin, TDeleteLimitsParams } from '@linkedapi/node';
2+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
3+
import z from 'zod';
4+
5+
import { AdminTool } from '../utils/admin-tool.js';
6+
7+
export class AdminDeleteLimitsTool extends AdminTool<TDeleteLimitsParams, void> {
8+
public readonly name = 'admin_delete_limits';
9+
protected readonly schema = z.object({
10+
accountId: z.string(),
11+
limits: z.array(
12+
z.object({
13+
category: z.string(),
14+
period: z.enum(['daily', 'weekly', 'monthly']),
15+
}),
16+
),
17+
});
18+
19+
public override async execute({
20+
admin,
21+
args,
22+
}: {
23+
admin: LinkedApiAdmin;
24+
args: TDeleteLimitsParams;
25+
}): Promise<void> {
26+
await admin.limits.delete(args);
27+
}
28+
29+
public override getTool(): Tool {
30+
return {
31+
name: this.name,
32+
description:
33+
'Delete specific rate limits for an account. Deleted limits fall back to system defaults.',
34+
inputSchema: {
35+
type: 'object',
36+
properties: {
37+
accountId: {
38+
type: 'string',
39+
description: 'Account UUID',
40+
},
41+
limits: {
42+
type: 'array',
43+
description: 'Array of limit keys to delete',
44+
items: {
45+
type: 'object',
46+
properties: {
47+
category: {
48+
type: 'string',
49+
description: 'Limit category',
50+
},
51+
period: {
52+
type: 'string',
53+
enum: ['daily', 'weekly', 'monthly'],
54+
description: 'Limit period',
55+
},
56+
},
57+
required: ['category', 'period'],
58+
},
59+
},
60+
},
61+
required: ['accountId', 'limits'],
62+
},
63+
};
64+
}
65+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { LinkedApiAdmin, TBillingLinkResult } from '@linkedapi/node';
2+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
3+
import z from 'zod';
4+
5+
import { AdminTool } from '../utils/admin-tool.js';
6+
7+
export class AdminGetBillingLinkTool extends AdminTool<Record<string, never>, TBillingLinkResult> {
8+
public readonly name = 'admin_get_billing_link';
9+
protected readonly schema = z.object({});
10+
11+
public override async execute({
12+
admin,
13+
}: {
14+
admin: LinkedApiAdmin;
15+
args: Record<string, never>;
16+
}): Promise<TBillingLinkResult> {
17+
return await admin.subscription.getBillingLink();
18+
}
19+
20+
public override getTool(): Tool {
21+
return {
22+
name: this.name,
23+
description: 'Get a Stripe billing portal link for the current workspace.',
24+
inputSchema: {
25+
type: 'object',
26+
properties: {},
27+
},
28+
};
29+
}
30+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import {
2+
LinkedApiAdmin,
3+
TConnectionSessionResult,
4+
TGetConnectionSessionParams,
5+
} from '@linkedapi/node';
6+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
7+
import z from 'zod';
8+
9+
import { AdminTool } from '../utils/admin-tool.js';
10+
11+
export class AdminGetConnectionSessionTool extends AdminTool<
12+
TGetConnectionSessionParams,
13+
TConnectionSessionResult
14+
> {
15+
public readonly name = 'admin_get_connection_session';
16+
protected readonly schema = z.object({
17+
sessionId: z.string(),
18+
});
19+
20+
public override async execute({
21+
admin,
22+
args,
23+
}: {
24+
admin: LinkedApiAdmin;
25+
args: TGetConnectionSessionParams;
26+
}): Promise<TConnectionSessionResult> {
27+
return await admin.accounts.getConnectionSession(args);
28+
}
29+
30+
public override getTool(): Tool {
31+
return {
32+
name: this.name,
33+
description: 'Get connection or reconnection session status by session ID.',
34+
inputSchema: {
35+
type: 'object',
36+
properties: {
37+
sessionId: {
38+
type: 'string',
39+
description: 'Connection session UUID',
40+
},
41+
},
42+
required: ['sessionId'],
43+
},
44+
};
45+
}
46+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { LinkedApiAdmin, TLimit } from '@linkedapi/node';
2+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
3+
import z from 'zod';
4+
5+
import { AdminTool } from '../utils/admin-tool.js';
6+
7+
export class AdminGetLimitsDefaultsTool extends AdminTool<
8+
Record<string, never>,
9+
{ limits: Array<TLimit> }
10+
> {
11+
public readonly name = 'admin_get_limits_defaults';
12+
protected readonly schema = z.object({});
13+
14+
public override async execute({
15+
admin,
16+
}: {
17+
admin: LinkedApiAdmin;
18+
args: Record<string, never>;
19+
}): Promise<{ limits: Array<TLimit> }> {
20+
return await admin.limits.getDefaults();
21+
}
22+
23+
public override getTool(): Tool {
24+
return {
25+
name: this.name,
26+
description: 'Get system default rate limits.',
27+
inputSchema: {
28+
type: 'object',
29+
properties: {},
30+
},
31+
};
32+
}
33+
}

0 commit comments

Comments
 (0)