Skip to main content
Glama
abhineet34

linkedin-mcp-server

Get LinkedIn Profile

linkedin_get_profile
Read-onlyIdempotent

Get the authenticated LinkedIn member's profile information: name, picture, email, and locale. Choose markdown or JSON output.

Instructions

Retrieve the authenticated LinkedIn member's profile information via the OIDC userinfo endpoint.

Returns the member's name, profile picture, email address, and locale.

Requires scopes: openid, profile, email

Args:

  • response_format ('markdown' | 'json'): Output format (default: 'markdown')

Returns: For JSON format: { "sub": string, // LinkedIn member URN (e.g., "urn:li:person:abc123") "name": string, // Full display name "given_name": string, // First name "family_name": string, // Last name "picture": string, // Profile picture URL (optional) "email": string, // Primary email address (optional) "email_verified": bool, // Whether email is verified (optional) "locale": { "country": string, // Country code "language": string // Language code } }

Examples:

  • Use when: "Who am I logged in as?" → call with default params

  • Use when: "Get my LinkedIn email" → call with response_format='json', read email field

  • Don't use when: You need to look up someone else's profile (LinkedIn doesn't expose that via standard API)

Error Handling:

  • Returns auth error if LINKEDIN_ACCESS_TOKEN is missing or expired

  • Returns permission error if 'profile' scope is not granted

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
response_formatNoOutput format: 'markdown' for human-readable or 'json' for machine-readablemarkdown

Implementation Reference

  • Registers the 'linkedin_get_profile' tool on the MCP server with its metadata, input schema, annotations, and handler. Called from src/index.ts line 30.
    export function registerProfileTools(server: McpServer): void {
      server.registerTool(
        "linkedin_get_profile",
        {
          title: "Get LinkedIn Profile",
          description: `Retrieve the authenticated LinkedIn member's profile information via the OIDC userinfo endpoint.
    
    Returns the member's name, profile picture, email address, and locale.
    
    Requires scopes: openid, profile, email
    
    Args:
      - response_format ('markdown' | 'json'): Output format (default: 'markdown')
    
    Returns:
      For JSON format:
      {
        "sub": string,           // LinkedIn member URN (e.g., "urn:li:person:abc123")
        "name": string,          // Full display name
        "given_name": string,    // First name
        "family_name": string,   // Last name
        "picture": string,       // Profile picture URL (optional)
        "email": string,         // Primary email address (optional)
        "email_verified": bool,  // Whether email is verified (optional)
        "locale": {
          "country": string,     // Country code
          "language": string     // Language code
        }
      }
    
    Examples:
      - Use when: "Who am I logged in as?" → call with default params
      - Use when: "Get my LinkedIn email" → call with response_format='json', read email field
      - Don't use when: You need to look up someone else's profile (LinkedIn doesn't expose that via standard API)
    
    Error Handling:
      - Returns auth error if LINKEDIN_ACCESS_TOKEN is missing or expired
      - Returns permission error if 'profile' scope is not granted`,
          inputSchema: GetProfileInputSchema,
          annotations: {
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: true,
          },
        },
        async (params: GetProfileInput) => {
          try {
            const profile = await v2Get<LinkedInProfile>("/userinfo");
    
            const structured = profile as unknown as Record<string, unknown>;
    
            if (params.response_format === ResponseFormat.JSON) {
              return {
                content: [{ type: "text", text: JSON.stringify(profile, null, 2) }],
                structuredContent: structured,
              };
            }
    
            const lines = [
              `# LinkedIn Profile`,
              "",
              `**Name:** ${profile.name}`,
              `**Sub (URN):** ${profile.sub}`,
            ];
            if (profile.email) lines.push(`**Email:** ${profile.email}`);
            if (profile.locale) {
              lines.push(`**Locale:** ${profile.locale.language}-${profile.locale.country}`);
            }
            if (profile.picture) lines.push(`**Picture:** ${profile.picture}`);
    
            return {
              content: [{ type: "text", text: lines.join("\n") }],
              structuredContent: structured,
            };
          } catch (error) {
            return { content: [{ type: "text", text: handleApiError(error) }] };
          }
        }
      );
    }
  • The async handler function that executes on tool call. Calls v2Get('/userinfo') to fetch the LinkedIn profile from the OIDC endpoint and returns either markdown or JSON format.
      async (params: GetProfileInput) => {
        try {
          const profile = await v2Get<LinkedInProfile>("/userinfo");
    
          const structured = profile as unknown as Record<string, unknown>;
    
          if (params.response_format === ResponseFormat.JSON) {
            return {
              content: [{ type: "text", text: JSON.stringify(profile, null, 2) }],
              structuredContent: structured,
            };
          }
    
          const lines = [
            `# LinkedIn Profile`,
            "",
            `**Name:** ${profile.name}`,
            `**Sub (URN):** ${profile.sub}`,
          ];
          if (profile.email) lines.push(`**Email:** ${profile.email}`);
          if (profile.locale) {
            lines.push(`**Locale:** ${profile.locale.language}-${profile.locale.country}`);
          }
          if (profile.picture) lines.push(`**Picture:** ${profile.picture}`);
    
          return {
            content: [{ type: "text", text: lines.join("\n") }],
            structuredContent: structured,
          };
        } catch (error) {
          return { content: [{ type: "text", text: handleApiError(error) }] };
        }
      }
    );
  • Zod schema for the input: accepts optional 'response_format' enum (markdown/json, defaults to markdown). Validated with .strict() to reject unknown fields.
    const GetProfileInputSchema = z
      .object({
        response_format: z
          .nativeEnum(ResponseFormat)
          .default(ResponseFormat.MARKDOWN)
          .describe("Output format: 'markdown' for human-readable or 'json' for machine-readable"),
      })
      .strict();
  • LinkedInProfile interface used by the handler — defines structure with sub, name, given_name, family_name, picture?, email?, email_verified?, locale? fields.
    export enum ResponseFormat {
      MARKDOWN = "markdown",
      JSON = "json",
    }
    
    export interface LinkedInProfile {
      sub: string;
      name: string;
      given_name: string;
      family_name: string;
      picture?: string;
      email?: string;
      email_verified?: boolean;
      locale?: { country: string; language: string };
    }
  • The v2Get helper function used by the handler to make authenticated GET requests to the LinkedIn v2 API. The handler calls v2Get<LinkedInProfile>('/userinfo').
    export async function v2Get<T>(path: string, params?: Record<string, unknown>): Promise<T> {
      const response = await axios.get<T>(`${LINKEDIN_API_V2_BASE}${path}`, {
        headers: buildHeaders(false),
        params,
        timeout: REQUEST_TIMEOUT_MS,
      });
      return response.data;
    }
Behavior5/5

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

Beyond annotations (readOnlyHint, idempotentHint, openWorldHint), the description details the authentication requirements (scopes), error cases (missing token, permission issues), and the exact structure of the response. No contradictions with annotations.

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 well-structured with clear sections (Args, Returns, Examples, Error Handling) and front-loaded with the core purpose. It is slightly verbose but every section adds value, making it efficient for an agent.

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

Completeness5/5

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

Given the simple parameter set, the presence of annotations, and no output schema, the description is remarkably complete. It includes the endpoint, scopes, all return fields, error handling, and example usage, leaving no critical gaps.

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

Parameters4/5

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

Schema coverage is 100%, and the description adds context by explaining the default value and providing usage examples for both formats. While the schema already defines the parameter, the description enhances it with practical guidance.

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

Purpose5/5

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

The description clearly states the tool retrieves the authenticated LinkedIn member's profile information via the OIDC userinfo endpoint, listing specific fields returned. It is easily distinguished from sibling tools like linkedin_create_post or linkedin_get_organization, which have different purposes.

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

Usage Guidelines5/5

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

Explicit when-to-use examples are provided (e.g., 'Who am I logged in as?'), a 'Don't use when' exclusion for looking up others' profiles, and required OAuth scopes are listed. This gives clear guidance on appropriate usage.

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/abhineet34/linkedin-mcp-server'

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