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
Copy file name to clipboardExpand all lines: README.md
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -110,7 +110,58 @@ agent = initialize_agent(
110
110
result = agent.run("What actions are available in Gmail?")
111
111
print(result)
112
112
```
113
+
### Using Model Context Protocol (MCP) Tools
113
114
115
+
The SDK supports integration with [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) servers, allowing you to connect to external tool providers via the MCP protocol.
116
+
117
+
```python
118
+
import asyncio
119
+
from langchain.agents import AgentType
120
+
from langchain_openai import ChatOpenAI
121
+
from pica_langchain import PicaClient, create_pica_agent
122
+
from pica_langchain.models import PicaClientOptions
123
+
124
+
# Configure MCP servers
125
+
mcp_options = {
126
+
"math": {
127
+
"command": "python",
128
+
"args": ["./path/to/math_server.py"],
129
+
"transport": "stdio",
130
+
},
131
+
"weather": {
132
+
"url": "http://localhost:8000/sse",
133
+
"transport": "sse",
134
+
}
135
+
}
136
+
137
+
asyncdefmain():
138
+
# Create client with async initialization
139
+
pica_client =await PicaClient.create(
140
+
secret="your-pica-secret",
141
+
options=PicaClientOptions(
142
+
connectors=["*"], # Initialize all available connections
143
+
mcp_options=mcp_options, # Add MCP server options
144
+
),
145
+
)
146
+
147
+
# Create an agent with both Pica and MCP tools
148
+
llm = ChatOpenAI(temperature=0, model="gpt-4o")
149
+
agent = create_pica_agent(
150
+
client=pica_client,
151
+
llm=llm,
152
+
agent_type=AgentType.OPENAI_FUNCTIONS,
153
+
)
154
+
155
+
# Use both Pica platform actions and MCP tools
156
+
result =await agent.ainvoke({
157
+
"input": "Calculate 25 * 17, then check the weather in New York, finally list all connectors Pica supported"
0 commit comments