CASE STUDY
Building a LinkedIn MCP Server: Connecting AI Assistants to LinkedIn
A custom MCP (Model Context Protocol) server that securely connects an AI assistant to a real LinkedIn account — using the same OAuth-secured pattern we apply across every integration we build.
Secure token-based authentication — zero hardcoded secrets
Same framework powering every MCP server we build
LinkedIn restricts write access to approved partners only
New scopes slot into the same server as they’re approved
What Is This, In Plain Language?
Imagine an AI assistant that’s great at talking and thinking, but has no hands — it can’t open LinkedIn, click a button, or read a profile. MCP is like giving that assistant a hand and a set of instructions: “here is a button labelled my_profile — press it, and I’ll hand you back the person’s LinkedIn info.” MCP doesn’t make the assistant smarter. It gives the assistant permission and a path to touch a real system, instead of guessing from memory.
The Challenge
LinkedIn is one of the most locked-down platforms for developers. Unlike a weather API or a hotel search API, LinkedIn doesn’t let just any app read a full profile or auto-publish content — every permission has to be explicitly granted through LinkedIn’s OAuth system, and most write-access (posting, messaging) requires separate, approved partner access. The goal: authenticate securely, expose LinkedIn data through the same MCP interface used across our other tools, and prove the pattern so broader access can slot in later with no rearchitecture.
The Solution: A Custom LinkedIn MCP Server
Built with FastMCP, the same framework behind our other MCP integrations. The access token is loaded securely from a local .env file — never hardcoded — using python-dotenv.
mcp = FastMCP("linkedin")
HEADERS = {
"Authorization": f"Bearer {ACCESS_TOKEN}",
"LinkedIn-Version": "202405",
}
@mcp.tool()
async def my_profile():
"""Get the authenticated LinkedIn user's profile."""
async with httpx.AsyncClient(timeout=30) as client:
response = await client.get(
"https://api.linkedin.com/v2/userinfo",
headers=HEADERS
)
return response.json()How It Works, Step by Step
my_profile() → a request to LinkedIn's userinfo endpoint.The current server can read a profile, but it can't publish posts. That's not a gap in the code — it's a wall LinkedIn puts up on purpose. Auto-publishing requires LinkedIn's Community Management API, which needs a separate, approved partner application. The takeaway for clients: an assistant that posts to a locked-down platform automatically is a two-part project — the MCP server code, which we can build in days, and the platform's own approval process, which is out of any developer's hands and can take longer.
Tech Stack
Frequently Asked Questions
Can this LinkedIn integration post or message on my behalf?
Not yet, by LinkedIn’s own design. Reading profile data works today; posting and messaging require LinkedIn’s separately-approved Community Management API, which is a platform approval process, not a code limitation.
How is the LinkedIn access token kept secure?
It’s loaded from a local .env file via python-dotenv and excluded from version control via .gitignore — never hardcoded into the source code, the same discipline we apply across every MCP server we build.
What is MCP, in one sentence?
MCP (Model Context Protocol) is a standard way to give an AI assistant real tools — a defined “button” it can press to fetch live data or take an action, instead of guessing from training data.
Can you build an MCP server for a different platform or internal tool?
Yes — this same pattern (FastMCP, secure OAuth or API-key handling, a clean tool interface) applies to any API or internal system you want an AI assistant to reach.
How long does a custom MCP server build like this take?
A single-platform integration like this one is typically a days-long build. Timeline mainly depends on how restrictive the target platform’s own API approval process is, not the MCP code itself.
Want an MCP Server Built for Your Platform?
If you want your AI assistant securely connected to LinkedIn, internal tools, or any other API — with proper OAuth handling and zero hardcoded secrets — we can design and build it the same way we built this one.