generate_linkedin_post
Create three LinkedIn post variations from any content source (articles, newsletters, notes, etc.) to enhance engagement and reach.
Instructions
Generate three LinkedIn post variants from any content (article, newsletter, notes, etc.) to optimize engagement.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The source content to transform into LinkedIn posts. Can be articles, emails, newsletters, notes, etc. | |
| content_type | No | Optional. A short description of the content type (e.g., 'article', 'newsletter', 'notes'). Defaults to 'article'. |
Implementation Reference
- cli.js:512-626 (handler)Handler for the 'generate_linkedin_post' tool. Validates input parameters (content and optional content_type), makes an HTTP POST request to the backend API (https://ligo.ertiqah.com/api/mcp/generate-linkedin-post), processes the response to return multiple post variants or error messages.} else if (name === 'generate_linkedin_post') { console.error(`${packageName}: Received call for generate_linkedin_post tool.`); const apiKey = process.env.LINKEDIN_MCP_API_KEY; const content = args?.content; const contentType = args?.content_type || 'article'; if (!apiKey) { sendResponse({ jsonrpc: "2.0", error: { code: -32001, message: "Server Configuration Error: API Key not set." }, id }); return; } if (typeof content !== 'string' || content.trim() === '') { sendResponse({ jsonrpc: "2.0", error: { code: -32602, message: "Invalid arguments: 'content' (string) required." }, id }); return; } try { const headers = { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json", "Accept": "application/json" }; const payload = { "content": content, "contentType": contentType }; console.error(`${packageName}: Calling generate post API: ${backendGeneratePostApiUrl} with payload:`, JSON.stringify(payload, null, 2)); const apiResponse = await axios.post(backendGeneratePostApiUrl, payload, { headers, timeout: 60000 }); console.error(`${packageName}: Generate post API response status: ${apiResponse.status}`); console.error(`${packageName}: Generate post API response data:`, JSON.stringify(apiResponse.data, null, 2)); if (apiResponse.data && apiResponse.data.success) { if (apiResponse.data.variants && Array.isArray(apiResponse.data.variants)) { // Handle the case where we get an array of variant posts const variants = apiResponse.data.variants; // Create content items - first a text description, then one item for each variant const contentItems = [ { type: "text", text: `Generated ${variants.length} LinkedIn post variants:` } ]; // Add each variant as a separate text item for better formatting variants.forEach((variant, index) => { contentItems.push({ type: "text", text: `Option ${index + 1}:\n${variant}` }); }); sendResponse({ jsonrpc: "2.0", result: { content: contentItems, isError: false }, id }); } else { // Fallback for backward compatibility sendResponse({ jsonrpc: "2.0", result: { content: [ { type: "text", text: apiResponse.data.message || "Successfully generated LinkedIn post, but no variants were returned. Please check the backend implementation." } ], isError: false }, id }); } } else { const errorMessage = apiResponse.data?.error || "Backend API Error (no detail)"; console.error(`${packageName}: Generate post API Error: ${errorMessage}`); sendResponse({ jsonrpc: "2.0", result: { content: [ { type: "text", text: `Failed to generate LinkedIn post: ${errorMessage}` } ], isError: true }, id }); } } catch (error) { let errorMessage = `Failed to call generate post API: ${error.message}`; if (error.response) { // Extract the error message directly from the backend response const backendError = error.response.data?.error || error.response.data?.message; errorMessage = backendError || `Backend API Error (Status ${error.response.status})`; console.error(`${packageName}: Generate post API Error Response:`, error.response.data); } else if (error.request) { errorMessage = "No response received from generate post API."; } console.error(`${packageName}: ${errorMessage}`); sendResponse({ jsonrpc: "2.0", result: { content: [ { type: "text", text: `Failed to generate LinkedIn post: ${errorMessage}` } ], isError: true }, id }); }
- cli.js:1305-1318 (schema)Input schema defining the parameters for the 'generate_linkedin_post' tool: required 'content' string and optional 'content_type' string.inputSchema: { type: "object", properties: { content: { type: "string", description: "The source content to transform into LinkedIn posts. Can be articles, emails, newsletters, notes, etc." }, content_type: { type: "string", description: "Optional. A short description of the content type (e.g., 'article', 'newsletter', 'notes'). Defaults to 'article'." } }, required: ["content"] }
- cli.js:1302-1319 (registration)Registration of the 'generate_linkedin_post' tool in the tools/list response, including name, description, and input schema.{ name: "generate_linkedin_post", description: "Generate three LinkedIn post variants from any content (article, newsletter, notes, etc.) to optimize engagement.", inputSchema: { type: "object", properties: { content: { type: "string", description: "The source content to transform into LinkedIn posts. Can be articles, emails, newsletters, notes, etc." }, content_type: { type: "string", description: "Optional. A short description of the content type (e.g., 'article', 'newsletter', 'notes'). Defaults to 'article'." } }, required: ["content"] } },
- cli.js:15-15 (helper)Backend API URL constant used by the generate_linkedin_post handler.const backendGeneratePostApiUrl = 'https://ligo.ertiqah.com/api/mcp/generate-linkedin-post';