Skip to content

A LangChain-based AI agent that generates and posts professional LinkedIn content from user input using OpenAI and the LinkedIn API.

Notifications You must be signed in to change notification settings

Vetrivel07/linkedin-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linkedin Post Agent

This project is a powerful and modular AI agent system that generates and posts professional LinkedIn content using OpenAI and LangChain, built with a clean MCP architecture. It takes an input idea from the user, transforms it into a high-quality LinkedIn post using a custom prompt template, and posts it directly to the user's LinkedIn profile using LinkedIn’s API.


🚀 Features

  • ✨ Human-style LinkedIn post generation with strict tone and structure guidelines
  • 🧠 LangChain agent powered by OpenAI LLM (gpt-4o)
  • 🧩 Modular MCP design: scalable and extendable with additional tools (e.g., X, Instagram)
  • 🔧 Built-in LinkedIn posting tool via LinkedIn REST API
  • 🖥️ Streamlit frontend for clean user interaction
  • 🔄 FastAPI backend for MCP logic orchestration

📦 Tech Stack

  • Python — Core backend language
  • Streamlit — Web application framework for UI
  • FastAPI — Backend API layer for handling requests and MCP orchestration
  • OpenAI GPT-4o — LLM used for generating high-quality, human-style LinkedIn posts
  • LangChain — Agent framework for chaining prompt execution and tool usage
  • LinkedIn REST API — Used to post directly to LinkedIn profiles

📁 Project Structure

/project-root/
├── streamlit_app/
│ └── app.py
│
├── mcp_server/ 
│   ├── main.py 
│   ├── agent_runner.py 
│   ├── llm/
│   │   └── llm_config.py 
│   ├── agents/
│   │   └── post_writer_agent.py 
│   └── tools/
│       └── linkedin_poster.py 
├── .env 
├── requirements.txt 
└── README.md # 

⚙️ How to Run the Project

1. Clone the Repository

git clone https://github.com/vetrivel07/linkedin-post-agent.git
cd linkedin-agent

2. Create and Activate Virtual Environment

python -m venv venv

Windows

venv\Scripts\activate

macOS / Linux

source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Configure Environment Variables

Create a .env file in the project root.

See Environment Variables section below for details.

Start the FastAPI Backend (MCP Server)

From the project root:

uvicorn mcp_server.main:app --host 0.0.0.0 --port 8000 --reload

Verify backend is running:

Open browser → http://localhost:8000/docs

Start the Streamlit Frontend

Open a second terminal, activate the same virtual environment, then:

streamlit run streamlit_app/app.py

The app will be available at:

http://localhost:8501

5. Generate & Post to LinkedIn

  1. Enter your LinkedIn post idea in the UI
  2. Click Generate & Post
  3. The agent:
    • Generates a professional post using OpenAI
    • Posts it to LinkedIn using your authorized account

🔐 Environment Variables

Create a .env file in the project root with the following variables:

# OpenAI
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxx

# LinkedIn OAuth (Application credentials)
LINKEDIN_ACCESS_TOKEN=your_access_token_here

# LinkedIn User Token (generated via OAuth)
LINKEDIN_URN=urn:li:person:your_urn_here

📸 Preview

Index Index


Author

👤 Vetrivel Maheswaran

Connect With Me 🌐

LinkedIn

PortFolio

© Created by Vetrivel Maheswaran

About

A LangChain-based AI agent that generates and posts professional LinkedIn content from user input using OpenAI and the LinkedIn API.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages