# Build a LangChain agent that drafts LinkedIn comments for approval

Source: https://finchreach.com/blog/langchain-linkedin-comment-drafts
Published 2026-10-28 by Finchreach team. Tags: langchain, linkedin, mcp, workflow-automation, comments, approval-queue.

A LangChain agent that finds LinkedIn posts on your topics, drafts thoughtful comments and queues them for your approval through Finchreach’s MCP server.

## The short answer

You can build a LangChain agent that keeps you visible on LinkedIn by drafting comments on posts in your niche. Load Finchreach’s tools into LangChain with `langchain-mcp-adapters`, give the agent your topics and your voice, and run it once or twice a day. It searches recent posts on those topics, picks a few worth engaging with, and drafts a specific, useful comment for each. The comments don’t post. With approval mode on, the default, each one waits in your Finchreach [approval queue](https://finchreach.com/approvals) until you approve it.

MCP (Model Context Protocol) is a standard plug that lets AI apps use outside tools. Finchreach is a remote MCP server for LinkedIn at `https://mcp.finchreach.com/mcp`, authenticated with an API key header. LangChain’s MCP adapters support Streamable HTTP with custom headers, so the agent connects directly.

## Why automate LinkedIn comments, and why not fully?

Thoughtful comments on other people’s posts are a common way to stay visible on LinkedIn without posting every day. They are also time-consuming: you have to find the right posts while they are still fresh, read them, and say something better than “Great point!”.

An agent is good at the finding and the first draft. It is not good at judgment about relationships, timing or tone, and a generic AI comment under someone’s post is worse than no comment. That is why this design keeps you in the loop for every comment. The agent does the legwork; you decide what goes out under your name.

## Which Finchreach tools does the agent use?

- `linkedin_search` with the content vertical to find posts by keyword, page by page.
- `linkedin_get_feed` with the recent sort to see what your network posted lately.
- `linkedin_comment_on_post` to draft a comment (up to 1,250 characters) on a post by its activity id. It returns `pending_approval`.
- `linkedin_react_to_post`, optionally, to queue a reaction alongside the comment.
- `linkedin_get_action` to check whether queued comments were approved and posted.

If you approve a comment and change your mind, `linkedin_delete_comment` removes it, using the comment id from the executed action.

## How do I connect LangChain to Finchreach?

The full walkthrough is in the [LangChain guide](https://finchreach.com/guides/langchain). The short version:

1. [Create a Finchreach account](https://finchreach.com/sign-up), connect your LinkedIn account on the Accounts page, and create an API key (it starts with `lk_`).
2. Install the adapters: `pip install langchain-mcp-adapters`, plus the agent and model packages you already use.
3. Create a `MultiServerMCPClient` with the `streamable_http` transport, the Finchreach URL and an `Authorization` header.
4. Load the tools with `get_tools()` and pass them to your agent.

agent.py (Python):
```text
import asyncio, os
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent

INSTRUCTIONS = open("comment_rules.md").read()

async def main():
    client = MultiServerMCPClient({"finchreach": {
        "transport": "streamable_http",
        "url": "https://mcp.finchreach.com/mcp",
        "headers": {"Authorization": "Bearer " + os.environ["FINCHREACH_API_KEY"]},
    }})
    tools = await client.get_tools()
    allowed = {"linkedin_search", "linkedin_get_feed", "linkedin_comment_on_post", "linkedin_get_action"}
    agent = create_react_agent("anthropic:claude-sonnet-5-5", [t for t in tools if t.name in allowed], prompt=INSTRUCTIONS)
    result = await agent.ainvoke({"messages": [("user", "Run today's comment round.")]})
    print(result["messages"][-1].content)

asyncio.run(main())
```

Filtering the tool list matters. An agent that only has search, feed, comment and status tools can’t send DMs or publish posts by accident. Run the script from cron, a CI schedule or any job runner; the drafts land in your queue either way.

> The `langchain-mcp-adapters` repository has been archived in favor of MCP support inside LangChain itself (`langchain[mcp]`), and newer LangChain docs describe a different adapter API, as of October 2026. The client shown above follows the adapters’ documented interface; check the [adapters repo](https://github.com/langchain-ai/langchain-mcp-adapters) and [LangChain’s MCP docs](https://docs.langchain.com/oss/python/langchain/mcp) for the current form. Our [quickstart](https://finchreach.com/docs) covers the Finchreach side.

## What rules should the comment agent follow?

Keep the rules in a file (here `comment_rules.md`) so you can tune them without touching code. A starting point:

> Ask your assistant: “You help me engage on LinkedIn. Search LinkedIn posts for “warehouse automation”, “3PL pricing” and “supply chain software”, and read my feed sorted by recent. Pick at most 3 posts from the last few days that are substantive (not job ads, not giveaways). For each, draft a comment under 500 characters that adds one concrete point from my experience running a 3PL, or asks one specific question. No flattery openers, no links, no selling, no emojis. Queue each comment with linkedin_comment_on_post. End with a list: author, first line of the post, your comment, action id.”

And a quick status check for the next run:

> Ask your assistant: “Check the action ids from yesterday’s run with linkedin_get_action and tell me which comments were approved, rejected or expired. Don’t draft new comments on posts where I rejected one.”

## How does approval work for an unattended agent?

Every Finchreach write, whether a comment, reaction, post, DM or invitation, becomes a pending action when approval mode is on. The agent gets `pending_approval` and an action id back, then moves on. You open the [approvals page](https://finchreach.com/approvals) when it suits you, read each comment next to its context, and approve or reject it. Only approved comments go live.

This also limits prompt injection. The agent reads text written by strangers, and a post could contain instructions aimed at AI agents. In the worst case that produces a strange draft, which you reject.

> Automating a personal LinkedIn account carries risk under LinkedIn’s User Agreement. The approval queue lowers that risk because a person reviews and paces every action, but it doesn’t remove it. Keep the number of comments per day small and the content genuinely yours.

## LangChain and LinkedIn: common questions

Can I use LangChain.js instead of Python? This post uses the Python adapters. Any MCP client library, in JavaScript or another language, that supports Streamable HTTP and custom headers will work with the same URL and header.

Which model should I use? Any tool-calling chat model that LangChain supports. Comment quality depends heavily on the model and your rules, so read the first few rounds closely.

Can the agent post its own LinkedIn posts? `linkedin_create_post` exists (text only, queued for approval), but leave it out of this agent’s tool list. Keep each agent to one job.

Prefer a visual builder? The same approval-queue pattern works in [n8n](https://finchreach.com/blog/n8n-linkedin-invitation-triage) and [Dify](https://finchreach.com/blog/dify-linkedin-inbox-triage). New to MCP? Read [what a LinkedIn MCP server is](https://finchreach.com/blog/what-is-a-linkedin-mcp-server).

Start your first comment round: [sign up for Finchreach](https://finchreach.com/sign-up) and follow the [LangChain guide](https://finchreach.com/guides/langchain).
