remove_connection
Remove a LinkedIn connection by providing the person's profile URL. Disconnect from unwanted contacts in your network.
Instructions
Allows you to remove a person from your connections (st.removeConnection action).
Input 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:1-32 (handler)The RemoveConnectionTool class that handles the remove_connection tool. Extends OperationTool, defines the schema (personUrl string) and getTool() method for tool registration. The actual execution logic is inherited from OperationTool (in utils/linked-api-tool.ts) which calls linkedapi.operations.find(...) and executeWithProgress.
import { OPERATION_NAME, TRemoveConnectionParams } from '@linkedapi/node'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; import { z } from 'zod'; import { OperationTool } from '../utils/linked-api-tool.js'; 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/tools/remove-connection.ts:10-12 (schema)Zod validation schema for remove_connection: requires a 'personUrl' string field.
protected override readonly schema = z.object({ personUrl: z.string(), }); - src/linked-api-tools.ts:56-56 (registration)Tool registration: RemoveConnectionTool is instantiated and added to the tools array in LinkedApiTools constructor.
new RemoveConnectionTool(progressCallback), - src/utils/linked-api-tool.ts:36-58 (helper)OperationTool base class that provides the shared execute() implementation. It finds the matching operation by operationName and delegates to executeWithProgress.
export abstract class OperationTool<TParams, TResult> extends LinkedApiTool<TParams, TResult> { public abstract readonly operationName: TOperationName; 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, }); } } - Generic workflow execution helper that runs the operation's workflow, provides progress notifications, and handles timeout errors for all tools including remove_connection.
import { LinkedApiWorkflowTimeoutError, Operation, TMappedResponse } from '@linkedapi/node'; import { LinkedApiProgressNotification } from './types'; 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; } }