Skip to main content
Glama

retrieve_connections

Retrieve LinkedIn connections with optional filters for names, positions, locations, industries, companies, or schools. Manage and analyze person-related data efficiently.

Instructions

allows you to retrieve your connections and perform additional person-related actions if needed (st.retrieveConnections action).

Input Schema

NameRequiredDescriptionDefault
filterNoOptional. Object that specifies filtering criteria for people. When multiple filter fields are specified, they are combined using AND logic.
limitNoOptional. Number of connections to return. Defaults to 500, with a maximum value of 1000.

Input Schema (JSON Schema)

{ "properties": { "filter": { "description": "Optional. Object that specifies filtering criteria for people. When multiple filter fields are specified, they are combined using AND logic.", "properties": { "currentCompanies": { "description": "Optional. Array of company names. Matches if person currently works at any of the listed companies.", "type": "array" }, "firstName": { "description": "Optional. First name of person.", "type": "string" }, "industries": { "description": "Optional. Array of enums representing industries. Matches if person works in any of the listed industries. Takes specific values available in the LinkedIn interface.", "type": "array" }, "lastName": { "description": "Optional. Last name of person.", "type": "string" }, "locations": { "description": "Optional. Array of free-form strings representing locations. Matches if person is located in any of the listed locations.", "type": "array" }, "position": { "description": "Optional. Job position of person.", "type": "string" }, "previousCompanies": { "description": "Optional. Array of company names. Matches if person previously worked at any of the listed companies.", "type": "array" }, "schools": { "description": "Optional. Array of institution names. Matches if person currently attends or previously attended any of the listed institutions.", "type": "array" } }, "type": "object" }, "limit": { "description": "Optional. Number of connections to return. Defaults to 500, with a maximum value of 1000.", "type": "number" } }, "type": "object" }

Implementation Reference

  • RetrieveConnectionsTool class: defines the tool name 'retrieve_connections', Zod input schema for validation, and getTool() method returning the MCP Tool interface with detailed inputSchema. Inherits execute() from OperationTool to invoke the LinkedIn API operation.
    export class RetrieveConnectionsTool extends OperationTool< TRetrieveConnectionsParams, TRetrieveConnectionsResult[] > { public override readonly name = 'retrieve_connections'; public override readonly operationName = OPERATION_NAME.retrieveConnections; protected override readonly schema = z.object({ limit: z.number().min(1).max(1000).optional(), filter: z .object({ firstName: z.string().optional(), lastName: z.string().optional(), position: z.string().optional(), locations: z.array(z.string()).optional(), industries: z.array(z.string()).optional(), currentCompanies: z.array(z.string()).optional(), previousCompanies: z.array(z.string()).optional(), schools: z.array(z.string()).optional(), }) .optional(), }); public override getTool(): Tool { return { name: this.name, description: 'allows you to retrieve your connections and perform additional person-related actions if needed (st.retrieveConnections action).', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Optional. Number of connections to return. Defaults to 10, with a maximum value of 1000.', }, filter: { type: 'object', description: 'Optional. Object that specifies filtering criteria for people. When multiple filter fields are specified, they are combined using AND logic.', properties: { firstName: { type: 'string', description: 'Optional. First name of person.', }, lastName: { type: 'string', description: 'Optional. Last name of person.', }, position: { type: 'string', description: 'Optional. Job position of person.', }, locations: { type: 'array', description: 'Optional. Array of free-form strings representing locations. Matches if person is located in any of the listed locations.', items: { type: 'string' }, }, industries: { type: 'array', description: 'Optional. Array of enums representing industries. Matches if person works in any of the listed industries. Takes specific values available in the LinkedIn interface.', items: { type: 'string' }, }, currentCompanies: { type: 'array', description: 'Optional. Array of company names. Matches if person currently works at any of the listed companies.', items: { type: 'string' }, }, previousCompanies: { type: 'array', description: 'Optional. Array of company names. Matches if person previously worked at any of the listed companies.', items: { type: 'string' }, }, schools: { type: 'array', description: 'Optional. Array of institution names. Matches if person currently attends or previously attended any of the listed institutions.', items: { type: 'string' }, }, }, }, }, }, }; }
  • Registration of RetrieveConnectionsTool instance (line 39) into the LinkedApiTools.tools array during constructor.
    this.tools = [ // Standard tools new SendMessageTool(progressCallback), new GetConversationTool(progressCallback), new CheckConnectionStatusTool(progressCallback), new RetrieveConnectionsTool(progressCallback), new SendConnectionRequestTool(progressCallback), new WithdrawConnectionRequestTool(progressCallback), new RetrievePendingRequestsTool(progressCallback), new RemoveConnectionTool(progressCallback), new SearchCompaniesTool(progressCallback), new SearchPeopleTool(progressCallback), new FetchCompanyTool(progressCallback), new FetchPersonTool(progressCallback), new FetchPostTool(progressCallback), new ReactToPostTool(progressCallback), new CommentOnPostTool(progressCallback), new RetrieveSSITool(progressCallback), new RetrievePerformanceTool(progressCallback), // Sales Navigator tools new NvSendMessageTool(progressCallback), new NvGetConversationTool(progressCallback), new NvSearchCompaniesTool(progressCallback), new NvSearchPeopleTool(progressCallback), new NvFetchCompanyTool(progressCallback), new NvFetchPersonTool(progressCallback), // Other tools new ExecuteCustomWorkflowTool(progressCallback), new GetWorkflowResultTool(progressCallback), new GetApiUsageTool(progressCallback), ];
  • OperationTool.execute method: core handler logic that resolves the specific API operation by operationName ('retrieveConnections') and invokes executeWithProgress to run the workflow.
    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, }); }
  • executeWithProgress helper: performs the actual LinkedAPI workflow execution (operation.execute and operation.result) with progress notifications and timeout handling.
    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; } }
  • Zod schema for input validation of retrieve_connections parameters (limit and filter object).
    protected override readonly schema = z.object({ limit: z.number().min(1).max(1000).optional(), filter: z .object({ firstName: z.string().optional(), lastName: z.string().optional(), position: z.string().optional(), locations: z.array(z.string()).optional(), industries: z.array(z.string()).optional(), currentCompanies: z.array(z.string()).optional(), previousCompanies: z.array(z.string()).optional(), schools: z.array(z.string()).optional(), }) .optional(), });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Linked-API/linkedapi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server