Skip to main content
Glama

get_linkedin_user_connections

Retrieve LinkedIn user connections data from your account, with options to filter by connection date and limit results for efficient network analysis.

Instructions

Get list of LinkedIn user connections. Account ID is taken from environment.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connected_afterNoFilter users that added after the specified date (timestamp)
countNoMax connections to return
timeoutNoTimeout in seconds

Implementation Reference

  • Handler and registration for 'get_linkedin_user_connections' tool. Makes API request to retrieve the authenticated user's LinkedIn connections with optional filters for time and count.
    server.tool(
      "get_linkedin_user_connections",
      "Get user's LinkedIn connections (requires ACCOUNT_ID)",
      {
        connected_after: z.number().optional().describe("Filter connections after timestamp"),
        count: z.number().default(20).describe("Max connections"),
        timeout: z.number().default(300).describe("Timeout in seconds")
      },
      async ({ connected_after, count, timeout }) => {
        const requestData: any = { timeout, account_id: ACCOUNT_ID, count };
        if (connected_after != null) {
          requestData.connected_after = connected_after;
        }
        log("Starting LinkedIn user connections lookup");
        try {
          const response = await makeRequest(API_CONFIG.ENDPOINTS.USER_CONNECTIONS, requestData);
          return {
            content: [{ type: "text", text: JSON.stringify(response, null, 2) }]
          };
        } catch (error) {
          log("LinkedIn user connections lookup error:", error);
          return {
            content: [{ type: "text", text: `LinkedIn user connections API error: ${formatError(error)}` }],
            isError: true
          };
        }
      }
    );
  • TypeScript interface defining the input arguments for the get_linkedin_user_connections tool.
    export interface GetLinkedinUserConnectionsArgs {
      connected_after?: number;
      count?: number;
      timeout?: number;
    }
  • Type guard function to validate input arguments for the get_linkedin_user_connections tool.
    export function isValidGetLinkedinUserConnectionsArgs(
      args: unknown
    ): args is GetLinkedinUserConnectionsArgs {
      if (typeof args !== "object" || args === null) return false;
      const obj = args as Record<string, unknown>;
      if (obj.connected_after !== undefined && typeof obj.connected_after !== "number") return false;
      if (obj.count !== undefined && typeof obj.count !== "number") return false;
      if (obj.timeout !== undefined && typeof obj.timeout !== "number") return false;
      return true;
    }
  • API endpoint constant used by the tool handler to fetch user connections.
    USER_CONNECTIONS: "/api/linkedin/management/user/connections",
  • Generic HTTP request helper function used by all tools including get_linkedin_user_connections to make API calls.
    const makeRequest = (endpoint: string, data: any, method: string = "POST"): Promise<any> => {
      return new Promise((resolve, reject) => {
        const url = new URL(endpoint, API_CONFIG.BASE_URL);
        const postData = JSON.stringify(data);
    
        const options = {
          hostname: url.hostname,
          port: url.port || 443,
          path: url.pathname,
          method: method,
          headers: {
            "Content-Type": "application/json",
            "Content-Length": Buffer.byteLength(postData),
            "access-token": API_KEY,
            ...(ACCOUNT_ID && { "x-account-id": ACCOUNT_ID })
          }
        };
    
        const req = https.request(options, (res) => {
          let responseData = "";
          res.on("data", (chunk) => {
            responseData += chunk;
          });
    
          res.on("end", () => {
            try {
              const parsed = JSON.parse(responseData);
              if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
                resolve(parsed);
              } else {
                reject(new Error(`API error ${res.statusCode}: ${JSON.stringify(parsed)}`));
              }
            } catch (e) {
              reject(new Error(`Failed to parse response: ${responseData}`));
            }
          });
        });
    
        req.on("error", (error) => {
          reject(error);
        });
    
        req.write(postData);
        req.end();
      });
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions that 'Account ID is taken from environment', which adds useful context about authentication. However, it lacks critical details: no information on rate limits, pagination (beyond the 'count' parameter), error handling, or what the returned list contains (e.g., fields like names, IDs). For a read operation with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two concise sentences. The first sentence states the core purpose, and the second adds authentication context. There's no wasted verbiage, and it's front-loaded with the main functionality. A minor deduction because the authentication note could be more integrated, but overall efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for a tool that retrieves social media connections. It lacks details on return format (e.g., structure of connection objects), error cases, or usage limits. The authentication hint is helpful but doesn't compensate for missing behavioral and output context, making it inadequate for reliable agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema. According to scoring rules, when coverage is high (>80%), the baseline is 3 even with no param info in the description, which applies here.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('list of LinkedIn user connections'), making the purpose unambiguous. It distinguishes from siblings by focusing specifically on user connections rather than posts, comments, or other LinkedIn entities. However, it doesn't explicitly differentiate from 'get_linkedin_profile' which might also retrieve user data, leaving minor ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'search_linkedin_users' or 'get_linkedin_profile'. It mentions that 'Account ID is taken from environment', which hints at authentication context but doesn't clarify prerequisites or exclusions. No explicit when/when-not instructions are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/anysiteio/hdw-mcp-server'

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