remove_connection
Remove a LinkedIn connection by specifying their profile URL. Integrates with MCP server to manage connections through AI assistants like Claude, Cursor, and VS Code.
Instructions
Allows you to remove a person from your connections (st.removeConnection action).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| personUrl | Yes | Public or hashed LinkedIn URL of the person you want to remove from your connections. (e.g., 'https://www.linkedin.com/in/john-doe') |
Implementation Reference
- src/tools/remove-connection.ts:7-32 (handler)RemoveConnectionTool class definition, including name 'remove_connection', schema, and MCP tool spec via getTool(). Delegates execution to base OperationTool.export class RemoveConnectionTool extends OperationTool<TRemoveConnectionParams, unknown> { public override readonly name = 'remove_connection'; public override readonly operationName = OPERATION_NAME.removeConnection; protected override readonly schema = z.object({ personUrl: z.string(), }); public override getTool(): Tool { return { name: this.name, description: 'Allows you to remove a person from your connections (st.removeConnection action).', inputSchema: { type: 'object', properties: { personUrl: { type: 'string', description: "Public or hashed LinkedIn URL of the person you want to remove from your connections. (e.g., 'https://www.linkedin.com/in/john-doe')", }, }, required: ['personUrl'], }, }; } }
- src/linked-api-tools.ts:43-43 (registration)Instantiates RemoveConnectionTool and registers it in the tools array of LinkedApiTools.new RemoveConnectionTool(progressCallback),
- src/utils/linked-api-tool.ts:39-58 (handler)OperationTool.execute method: resolves the operation by operationName and invokes executeWithProgress to run the LinkedAPI operation.public override execute({ linkedapi, args, workflowTimeout, progressToken, }: { linkedapi: LinkedApi; args: TParams; workflowTimeout: number; progressToken?: string | number; }): Promise<TMappedResponse<TResult>> { const operation = linkedapi.operations.find( (operation) => operation.operationName === this.operationName, )! as Operation<TParams, TResult>; return executeWithProgress(this.progressCallback, operation, workflowTimeout, { params: args, progressToken, }); } }
- Helper function that executes the LinkedAPI operation with progress notifications, timeout handling, and result polling.export async function executeWithProgress<TParams, TResult>( progressCallback: (progress: LinkedApiProgressNotification) => void, operation: Operation<TParams, TResult>, workflowTimeout: number, { params, workflowId, progressToken, }: { params?: TParams; workflowId?: string; progressToken?: string | number } = {}, ): Promise<TMappedResponse<TResult>> { let progress = 0; progressCallback({ progressToken, progress, total: 100, message: `Starting workflow ${operation.operationName}...`, }); const interval = setInterval( () => { if (progress < 50) { progress += 5; } else if (progress < 98) { progress += 1; } progressCallback({ progressToken, progress, total: 100, message: `Executing workflow ${operation.operationName}...`, }); }, Math.max(workflowTimeout / 20, 10000), ); try { if (!workflowId) { workflowId = await operation.execute(params as TParams); } const result = await operation.result(workflowId, { timeout: workflowTimeout, }); clearInterval(interval); progressCallback({ progressToken, progress: 100, total: 100, message: `Workflow ${operation.operationName} completed successfully`, }); return result; } catch (error) { clearInterval(interval); if (error instanceof LinkedApiWorkflowTimeoutError) { throw generateTimeoutError(error); } throw error; } }
- src/linked-api-server.ts:26-108 (handler)LinkedApiMCPServer.executeWithTokens: MCP call_tool handler that selects the tool by name, validates args, calls tool.execute, and formats response.public async executeWithTokens( request: ExtendedCallToolRequest['params'], { linkedApiToken, identificationToken, mcpClient }: TLinkedApiConfig & { mcpClient: string }, ): Promise<CallToolResult> { const workflowTimeout = defineRequestTimeoutInSeconds(mcpClient) * 1000; logger.info( { toolName: request.name, arguments: request.arguments, mcpClient, workflowTimeout, }, 'Tool execution started', ); const linkedapi = new LinkedApi( buildLinkedApiHttpClient( { linkedApiToken: linkedApiToken, identificationToken: identificationToken, }, 'mcp', ), ); const { name: toolName, arguments: args, _meta } = request; const progressToken = _meta?.progressToken; const startTime = Date.now(); try { const tool = this.tools.toolByName(toolName)!; const params = tool.validate(args); const { data, errors } = await tool.execute({ linkedapi, args: params, workflowTimeout, progressToken, }); const endTime = Date.now(); const duration = `${((endTime - startTime) / 1000).toFixed(2)} seconds`; if (errors.length > 0 && !data) { logger.error( { toolName, duration, errors, }, 'Tool execution failed', ); return { content: [ { type: 'text' as const, text: errors.map((e) => e.message).join('\n'), }, ], }; } logger.info( { toolName, duration, data, }, 'Tool execution successful', ); if (data) { return { content: [ { type: 'text' as const, text: JSON.stringify(data, null, 2), }, ], }; } return { content: [ { type: 'text' as const, text: 'Completed', }, ], };