Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@linkedapi/mcp",
"version": "2.3.18",
"version": "2.3.19",
"description": "MCP server that lets AI assistants control LinkedIn accounts and retrieve real-time data.",
"main": "dist/index.js",
"bin": {
Expand Down
26 changes: 0 additions & 26 deletions src/tools/accept-invitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,32 +59,6 @@ export class AcceptInvitationTool extends OperationTool<TAcceptInvitationParams,
},
required: ['invitationType'],
additionalProperties: false,
oneOf: [
{
properties: {
invitationType: { const: 'connect' },
personUrl: { type: 'string' },
},
required: ['invitationType', 'personUrl'],
additionalProperties: false,
},
{
properties: {
invitationType: { const: 'companyFollow' },
companyUrl: { type: 'string' },
},
required: ['invitationType', 'companyUrl'],
additionalProperties: false,
},
{
properties: {
invitationType: { const: 'newsletterSubscribe' },
newsletterUrl: { type: 'string' },
},
required: ['invitationType', 'newsletterUrl'],
additionalProperties: false,
},
],
} as Tool['inputSchema'],
};
}
Expand Down
3 changes: 1 addition & 2 deletions src/tools/execute-custom-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ExecuteCustomWorkflowTool extends OperationTool<
},
definition: {
description: 'A single-action or array workflow definition.',
oneOf: [
anyOf: [
{
type: 'object',
properties: {
Expand Down Expand Up @@ -73,7 +73,6 @@ export class ExecuteCustomWorkflowTool extends OperationTool<
],
},
},
anyOf: [{ required: ['actionType'] }, { required: ['definition'] }],
additionalProperties: true,
},
};
Expand Down
4 changes: 2 additions & 2 deletions src/tools/fetch-post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class FetchPostTool extends OperationTool<TFetchPostParams, unknown> {
.optional(),
reactionsRetrievalConfig: z
.object({
limit: z.number().min(1).max(1000).optional(),
limit: z.number().min(1).max(500).optional(),
})
.optional(),
});
Expand Down Expand Up @@ -84,7 +84,7 @@ export class FetchPostTool extends OperationTool<TFetchPostParams, unknown> {
limit: {
type: 'number',
description:
'Optional. Max number of reactions to retrieve. Defaults to 10, with a maximum value of 1000.',
'Optional. Max number of reactions to retrieve. Defaults to 10, with a maximum value of 500.',
},
},
},
Expand Down
26 changes: 0 additions & 26 deletions src/tools/ignore-invitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,32 +59,6 @@ export class IgnoreInvitationTool extends OperationTool<TIgnoreInvitationParams,
},
required: ['invitationType'],
additionalProperties: false,
oneOf: [
{
properties: {
invitationType: { const: 'connect' },
personUrl: { type: 'string' },
},
required: ['invitationType', 'personUrl'],
additionalProperties: false,
},
{
properties: {
invitationType: { const: 'companyFollow' },
companyUrl: { type: 'string' },
},
required: ['invitationType', 'companyUrl'],
additionalProperties: false,
},
{
properties: {
invitationType: { const: 'newsletterSubscribe' },
newsletterUrl: { type: 'string' },
},
required: ['invitationType', 'newsletterUrl'],
additionalProperties: false,
},
],
} as Tool['inputSchema'],
};
}
Expand Down
5 changes: 2 additions & 3 deletions src/tools/search-posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const COMPANY_FILTER_ENTRY_SCHEMA = z.union([
]);

const PERSON_FILTER_ENTRY_JSON_SCHEMA = {
oneOf: [
anyOf: [
{
type: 'string',
minLength: 1,
Expand Down Expand Up @@ -53,7 +53,7 @@ const PERSON_FILTER_ENTRY_JSON_SCHEMA = {
};

const COMPANY_FILTER_ENTRY_JSON_SCHEMA = {
oneOf: [
anyOf: [
{
type: 'string',
minLength: 1,
Expand Down Expand Up @@ -202,7 +202,6 @@ export class SearchPostsTool extends OperationTool<TSearchPostsParams, unknown>
'Optional. URL copied from a LinkedIn content search page after configuring filters. When specified, filter is ignored entirely.',
},
},
anyOf: [{ required: ['term'] }, { required: ['customSearchUrl'] }],
} as Tool['inputSchema'],
};
}
Expand Down
4 changes: 3 additions & 1 deletion src/utils/admin-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import { LinkedApiAdmin } from '@linkedapi/node';
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import z from 'zod';

import { unwrapValueEnvelope } from './unwrap-value-envelope.js';

export abstract class AdminTool<TParams, TResult> {
public abstract readonly name: string;
protected abstract readonly schema: z.ZodSchema;

public abstract getTool(): Tool;

public validate(args: unknown): TParams {
return this.schema.parse(args) as TParams;
return this.schema.parse(unwrapValueEnvelope(args, this.getTool().inputSchema)) as TParams;
}

public abstract execute({
Expand Down
4 changes: 3 additions & 1 deletion src/utils/linked-api-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import z from 'zod';

import type { TLinkedApiToolResult, TWorkflowAck } from '../types/linked-api-tool-result.type.js';

import { unwrapValueEnvelope } from './unwrap-value-envelope.js';

interface TLinkedApiToolExecuteOptions<TParams> {
linkedapi: LinkedApi;
args: TParams;
Expand All @@ -18,7 +20,7 @@ export abstract class LinkedApiTool<TParams, TResult> {
public abstract getTool(): Tool;

public validate(args: unknown): TParams {
return this.schema.parse(args) as TParams;
return this.schema.parse(unwrapValueEnvelope(args, this.getTool().inputSchema)) as TParams;
}

public abstract execute(
Expand Down
4 changes: 3 additions & 1 deletion src/utils/public-tool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import z from 'zod';

import { unwrapValueEnvelope } from './unwrap-value-envelope.js';

// Tools backed by public Linked API endpoints: they get no client and run without any token.
export abstract class PublicTool<TParams, TResult> {
public abstract readonly name: string;
Expand All @@ -9,7 +11,7 @@ export abstract class PublicTool<TParams, TResult> {
public abstract getTool(): Tool;

public validate(args: unknown): TParams {
return this.schema.parse(args) as TParams;
return this.schema.parse(unwrapValueEnvelope(args, this.getTool().inputSchema)) as TParams;
}

public abstract execute({ args }: { args: TParams }): Promise<TResult>;
Expand Down
22 changes: 22 additions & 0 deletions src/utils/unwrap-value-envelope.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Tool } from '@modelcontextprotocol/sdk/types.js';

function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null && !Array.isArray(value);
}

// ChatGPT cannot take a tool whose inputSchema has anyOf/oneOf at its root, and calls such a tool with
// its arguments wrapped as { value: {...} }. No root combinators are listed any more, but a client
// can keep calling with a tool list it fetched earlier, so a lone `value` object is still unwrapped
// for every tool that does not declare a parameter of that name.
export function unwrapValueEnvelope(args: unknown, inputSchema: Tool['inputSchema']): unknown {
if (!isRecord(args) || inputSchema.properties?.['value'] !== undefined) {
return args;
}

const { value, ...rest } = args;
if (Object.keys(rest).length > 0 || !isRecord(value)) {
return args;
}

return value;
}
Loading