You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> **Why the `[crewai]` extra?** CrewAI requires `nest-asyncio` to bridge CrewAI's synchronous tool interface with MCP's asynchronous client. LangChain and OpenAI Agents have native async support and work with the base installation.
39
+
33
40
### Basic Usage (CLI/Desktop Apps)
34
41
35
42
For simple command-line tools or desktop applications, create a file `src/mcp_cli/__init__.py`:
@@ -610,6 +617,18 @@ Follow the authorization link, and then refresh the page. It should show the too
610
617
611
618
## AI Agent Integrations
612
619
620
+
The MCP client provides integrations for popular AI agent frameworks. Each framework has different async support:
621
+
622
+
| Framework | Installation | Extra Required? | Why |
|**LangChain**|`uv add keycardai-mcp langchain`| No | Native async support via `coroutine=` parameter |
625
+
|**OpenAI Agents**|`uv add keycardai-mcp openai-agents`| No | Native async support |
626
+
|**CrewAI**|`uv add "keycardai-mcp[crewai]"`|**Yes**| Requires `nest-asyncio` for sync/async bridge |
627
+
628
+
> **Technical Note:** CrewAI tools use synchronous methods (`_run()`), while MCP clients are async. The `[crewai]` extra includes `nest-asyncio` to enable nested event loops for seamless integration.
629
+
630
+
---
631
+
613
632
### How Authentication Works with AI Agents
614
633
615
634
The MCP client provides AI framework integrations that automatically handle authentication flows. Here's how it works:
@@ -835,6 +854,91 @@ Run the OpenAI agent:
835
854
uv run mcp-openai
836
855
```
837
856
857
+
### CrewAI
858
+
859
+
Install dependencies:
860
+
861
+
```bash
862
+
uv add "keycardai-mcp[crewai]"
863
+
```
864
+
865
+
Set your OpenAI API key:
866
+
867
+
```bash
868
+
export OPENAI_API_KEY="sk-..."
869
+
```
870
+
871
+
Create `src/mcp_crewai/__init__.py`:
872
+
873
+
```python
874
+
import asyncio
875
+
from crewai import Agent, Task, Crew
876
+
from langchain_openai import ChatOpenAI
877
+
878
+
from keycardai.mcp.client import Client
879
+
from keycardai.mcp.client.integrations.crewai_agents import CrewAIClient
880
+
881
+
servers = {
882
+
"my-server": {
883
+
"url": "http://localhost:7878/mcp",
884
+
"transport": "http",
885
+
"auth": {"type": "oauth"}
886
+
}
887
+
}
888
+
889
+
asyncdefrun():
890
+
asyncwith Client(servers) as mcp_client:
891
+
# Wrap MCP client for CrewAI
892
+
asyncwith CrewAIClient(mcp_client) as crewai_client:
893
+
# Get tools converted to CrewAI format
894
+
tools =await crewai_client.get_tools()
895
+
print(f"Available tools: {len(tools)}")
896
+
897
+
# Get system prompt
898
+
system_prompt = crewai_client.get_system_prompt(
899
+
"You are a helpful assistant with access to MCP tools."
0 commit comments