Skip to main content
Glama

generate_linkedin_post

Generate LinkedIn post drafts from YouTube video content by summarizing key points and applying specified tone and hashtags.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
summaryYesSummary of the video content
videoTitleYesTitle of the YouTube video
speakerNameNoName of the speaker in the video (optional)
hashtagsNoRelevant hashtags (optional)
toneNoTone of the LinkedIn postfirst-person
includeCallToActionNoWhether to include a call to action

Implementation Reference

  • Core handler function that generates a LinkedIn post using OpenAI GPT based on video summary, title, speaker, hashtags, tone, etc.
    export async function generateLinkedInPost(
      summary, 
      videoTitle, 
      speakerName = null, 
      hashtags = [], 
      tone = "first-person", 
      includeCallToAction = true,
      apiKey
    ) {
      if (!apiKey) {
        throw new Error("OpenAI API key not provided");
      }
      
      if (!summary || summary.trim().length === 0) {
        throw new Error("Empty summary provided");
      }
      
      console.log(`Generating LinkedIn post with tone: ${tone}`);
      
      try {
        // Initialize OpenAI client with provided API key
        const openai = new OpenAI({
          apiKey: apiKey,
        });
        
        // Prepare hashtag string
        const hashtagString = hashtags && hashtags.length > 0 
          ? hashtags.map(tag => tag.startsWith('#') ? tag : `#${tag}`).join(' ')
          : '';
        
        // Prepare speaker reference
        const speakerReference = speakerName ? `by ${speakerName}` : '';
        
        const response = await openai.chat.completions.create({
          model: "gpt-3.5-turbo",
          messages: [
            {
              role: "system",
              content: `You are a professional LinkedIn content creator. 
              Create a compelling LinkedIn post in a ${tone} tone based on the provided video summary.
              The post should be between 500-1200 characters (not including hashtags).
              
              Structure the post with:
              1. An attention-grabbing hook
              2. 2-3 key insights from the video
              3. A personal reflection or takeaway
              ${includeCallToAction ? '4. A soft call to action (e.g., asking a question, inviting comments)' : ''}
              
              The post should feel authentic, professional, and valuable to LinkedIn readers.
              Avoid clickbait or overly promotional language.`
            },
            {
              role: "user",
              content: `Create a LinkedIn post based on this YouTube video:
              
              Title: ${videoTitle} ${speakerReference}
              
              Summary:
              ${summary}
              
              ${hashtagString ? `Suggested hashtags: ${hashtagString}` : ''}
              
              Please format the post ready to copy and paste to LinkedIn.`
            }
          ],
          temperature: 0.7,
          max_tokens: 700
        });
        
        if (response.choices && response.choices.length > 0) {
          let post = response.choices[0].message.content.trim();
          
          // Ensure hashtags are at the end if they weren't included
          if (hashtagString && !post.includes(hashtagString)) {
            post += `\n\n${hashtagString}`;
          }
          
          return post;
        } else {
          throw new Error("No post generated");
        }
      } catch (error) {
        console.error("Post generation error:", error);
        throw new Error(`Failed to generate LinkedIn post: ${error.message}`);
      }
    }
  • src/server.js:167-220 (registration)
    MCP tool registration for 'generate_linkedin_post' including Zod input schema, wrapper handler that checks API key and calls the core generateLinkedInPost function, and description.
    server.tool(
      "generate_linkedin_post",
      { 
        summary: z.string().describe("Summary of the video content"),
        videoTitle: z.string().describe("Title of the YouTube video"),
        speakerName: z.string().optional().describe("Name of the speaker in the video (optional)"),
        hashtags: z.array(z.string()).optional().describe("Relevant hashtags (optional)"),
        tone: z.enum(["first-person", "third-person", "thought-leader"])
          .default("first-person")
          .describe("Tone of the LinkedIn post"),
        includeCallToAction: z.boolean().default(true)
          .describe("Whether to include a call to action")
      },
      async ({ summary, videoTitle, speakerName, hashtags, tone, includeCallToAction }) => {
        try {
          // Check if OpenAI API key is set
          if (!apiKeyManager.hasOpenAIKey()) {
            throw new Error("OpenAI API key not set. Please use the set_api_keys tool first.");
          }
          
          const post = await generateLinkedInPost(
            summary, 
            videoTitle, 
            speakerName, 
            hashtags, 
            tone, 
            includeCallToAction,
            apiKeyManager.getOpenAIKey()
          );
          
          return {
            content: [{ 
              type: "text", 
              text: JSON.stringify({
                success: true,
                post
              }, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{ 
              type: "text", 
              text: JSON.stringify({
                success: false,
                error: error.message
              }, null, 2)
            }],
            isError: true
          };
        }
      },
      { description: "Generate a LinkedIn post draft from a video summary" }
    );
  • Zod schema defining input parameters for the generate_linkedin_post tool.
    { 
      summary: z.string().describe("Summary of the video content"),
      videoTitle: z.string().describe("Title of the YouTube video"),
      speakerName: z.string().optional().describe("Name of the speaker in the video (optional)"),
      hashtags: z.array(z.string()).optional().describe("Relevant hashtags (optional)"),
      tone: z.enum(["first-person", "third-person", "thought-leader"])
        .default("first-person")
        .describe("Tone of the LinkedIn post"),
      includeCallToAction: z.boolean().default(true)
        .describe("Whether to include a call to action")
    },
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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/NvkAnirudh/LinkedIn-Post-Generator'

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