WEIR

CrewAI MCP: Connect a Remote Server with MCPServerHTTP

Set up CrewAI MCP tools from a remote server: MCPServerHTTP with a bearer key, a tool filter, the names agents see, a real 401 fix and real X output.


Published · Updated · 6 min read

Cover image: X research in a CrewAI crew

CrewAI MCP support lives in the agent's mcps field: pass an MCPServerHTTP with the server URL and an auth header.

This guide is for Python developers building a research crew. It connects Weir's remote MCP server for public X (Twitter) data, trims the tool list and shows a real call with its cost. We run Weir.

import os
from crewai import Agent
from crewai.mcp import MCPServerHTTP

weir = MCPServerHTTP(
    url="https://api.weirapp.io/mcp",
    headers={"Authorization": f"Bearer {os.environ['WEIR_API_KEY']}"},
)
analyst = Agent(role="X analyst", goal="Report on public X posts",
                backstory="You link every post you cite.", mcps=[weir])

How to connect a CrewAI MCP server with a key

You need CrewAI, a Weir key and a model key.

No extra package is needed, since crewai already depends on the mcp SDK.

  1. Installpip install crewai in a Python 3.10 to 3.13 virtual environment.
  2. Get a Weir keyCreate one under API keys in your Weir dashboard. Keep it in WEIR_API_KEY.
  3. Set a model keyCrewAI defaults to OpenAI's gpt-4.1-mini, so set OPENAI_API_KEY.
  4. Run the crewGive the agent mcps=[weir] and call kickoff() on the crew.

As of 24 October 2026, PyPI lists crewai 1.15.30, released that morning. Expect a big install: it pulls in ChromaDB, LanceDB and OpenTelemetry.

Why not the short string form? CrewAI's MCP docs show mcps=["https://mcp.exa.ai/mcp?api_key=..."], with the key in the URL. Weir ignores keys in URLs, so that form gets a 401.

CrewAI MCP example: a research crew on X

The script is 23 lines, in two parts. Part one sets up the server with a filter and a cached tool list:

import os
from crewai import Agent, Crew, Task
from crewai.mcp import MCPServerHTTP
from crewai.mcp.filters import create_static_tool_filter

weir = MCPServerHTTP(
    url="https://api.weirapp.io/mcp",
    headers={"Authorization": f"Bearer {os.environ['WEIR_API_KEY']}"},
    tool_filter=create_static_tool_filter(allowed_tool_names=["search_x", "get_x_post"]),
    cache_tools_list=True,
)

Part two adds the agent and task, then runs the crew:

analyst = Agent(
    role="X analyst",
    goal="Report what AI framework teams post about MCP",
    backstory="You search X with limit 5 or less and link every post you cite.",
    mcps=[weir],
)
task = Task(
    description="What have @crewAIInc and @LangChain posted about MCP lately?",
    expected_output="Three bullets, each with a date, one line and a link.",
    agent=analyst,
)
print(Crew(agents=[analyst], tasks=[task]).kickoff())

Here's what CrewAI does with it, per its 1.15.30 source:

  • It lists tools when a task starts. With cache_tools_list=True, it keeps that list for 5 minutes.
  • Each tool call opens its own connection. That suits Weir, which keeps no session between requests.
  • The agent reads every text block. Weir sends the JSON result, then a line such as "Charged 4 credits; 617 credits left."

Is the crew sync or async? kickoff() blocks until the crew ends.

Inside, CrewAI runs each MCP call with asyncio.run, or in a worker thread when an event loop is already running. So MCP calls also work inside a notebook, and async apps can await crew.akickoff().

What does the agent get back?

To answer, the agent calls search_x with both handles and a keyword. We made that call through Weir's MCP server on 24 October 2026:

→ search_x {"fromUsers": ["crewAIInc", "LangChain"], "query": "MCP -filter:nativeretweets",
            "onlyOriginal": true, "limit": 3}
← 3 posts · 4 credits · nextCursor set
  2026-10-07  37 likes  @LangChain  "Managed Deep Agents v0.9 is here!", MCP servers per run
  2026-10-01  33 likes  @LangChain  "@langchain / MCP-adapters 2.0", quoting @LangChain_JS
  2026-09-15  88 likes  @LangChain  "Every Managed Deep Agent is an MCP server."

Each post arrives with its url, text and counts, so the agent can link every claim.

The three newest matches all came from @LangChain. A good agent then searches @crewAIInc on its own.

Weir also returns meta.next, the whole follow-up call with the new cursor. Its docs say only a null cursor marks the end.

4credits for the search above
11credits for a 10-post search
1credit for a search that finds nothing
5,000free Weir credits every month

Weir bills 1 credit per call plus 1 per X post, and failed calls are free. Paid packs start at $5 for 25,000 credits and never expire, as of October 2026. Every rate is on our pricing page.

Which CrewAI MCP tools does the agent see?

A default Weir key lists more than 40 tools, Reddit and monitors included.

Each tool adds its description to the prompt, and a short list means fewer wrong picks. Three settings trim it:

Setting What it does
create_static_tool_filter Keeps allowed names; a blocked name loses
A filter function Any rule you can write in Python
A key without Reddit Weir stops listing its 12 Reddit tools

Filters match Weir's own names, like search_x. The agent sees a prefix built from the URL, so match the short name in code and expect the long one in logs.

This filter function keeps every X tool. Pass it as tool_filter=x_tools_only:

def x_tools_only(context, tool: dict) -> bool:
    return tool["name"].startswith(("search_x", "get_x_"))

Prefer to hold one connection yourself? MCPServerAdapter from crewai-tools takes {"url": ..., "transport": "streamable-http", "headers": {...}}. Leave out transport and it falls back to SSE, which Weir doesn't serve.

If it doesn't work

This is what Weir sent our curl call with no key, on 24 October 2026:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://api.weirapp.io/.well-known/
  oauth-protected-resource/mcp", scope="read:social usage:read monitors:read"
{"error":"unauthorized","error_description":"Authorization is required."}

CrewAI reports it as "MCP server refused the connection with HTTP 401 Unauthorized". The challenge is meant for apps that sign in through a browser, and CrewAI doesn't. The fixes:

  • 401 with a key set. The header must read Bearer weir_live_.... Check the key with Weir's free GET /v1/whoami.
  • "No tools discovered". Your filter matched nothing. Filter on search_x, not the prefixed name.
  • A slow search runs again. CrewAI gives a tool call 30 seconds, with up to 3 attempts after a timeout. Each retry that succeeds is a new, billed search, so keep limit small.
  • A tool returns 402. Your Weir credits ran out. CrewAI hands the agent a tool failure, and retrying won't help.

When not to use Weir

  • Your crew has to post or DM on X. Weir is read-only.
  • You want private data. Weir reads public posts, not bookmarks, DMs or home timelines.
  • Price per post matters most. TwitterAPI.io lists $0.15 per 1,000 tweets as of October 2026, less than our $5 pack.
  • You need a guarantee. Weir isn't licensed by X or affiliated with it, so access can change.

FAQ

Does CrewAI have an MCP integration?

Yes. CrewAI's docs call the agent's mcps field the recommended way in. It takes HTTPS URLs, CrewAI catalog slugs, and MCPServerStdio, MCPServerHTTP or MCPServerSSE configs. MCPServerAdapter in crewai-tools is the manual route.

How do I pass an API key to a CrewAI MCP server?

Put it in headers on MCPServerHTTP, as the script does, and CrewAI sends it on every request. The URL form only works for servers that read a key from the query string. Weir doesn't.

What is the difference between mcps and MCPServerAdapter?

With mcps, CrewAI connects, lists and calls tools for you, one connection per call. MCPServerAdapter holds one connection open inside a with block. Its tools stop working when the block ends.

Can a CrewAI agent post to X through Weir?

No. Weir only reads public X data, so nothing can post, like or follow through it. For posting, use a tool that holds your own X account's access.

Sources

All checked on 24 October 2026.