GET STARTED
OPERARATION
AGENTS
Tools
Agents can invoke tools in Python or via MCP
Python Functions as Tools
You can find all the code for this example on Github.
images/main/main.py
Copy
from datetime import datetime
from ockam import Agent, Model, Node, Tool
def current_iso8601_utc_time():
"""
Returns the current UTC time in ISO 8601 format.
"""
return datetime.utcnow().isoformat() + "Z"
async def main(node):
await Agent.start(
node=node,
name="henry",
instructions="You are Henry, an expert legal assistant",
model=Model("claude-3-7-sonnet-v1"),
tools=[Tool(current_iso8601_utc_time)],
)
Node.start(main)
Copy
http POST \
"https://25df35de87aa441b88f22a6c2a830a17-example006.ai.ockam.network/agents/henry" message="what is the current time"
Tools provided by MCP Servers
You can find all the code for this example on Github.
ockam.yaml
Copy
name: example007
pods:
- name: main-pod
public: true
containers:
- name: main
image: main
- name: mcp
image: ghcr.io/build-trust/mcp-proxy
env:
- name: BRAVE_API_KEY
valueFrom:
secretKeyRef:
name: brave
key: key
args:
["--sse-port", "8001", "--pass-environment",
"--", "npx", "-y", "@modelcontextprotocol/server-brave-search"]
secrets.yaml
Copy
- name: brave
fields:
key: "YOUR KEY HERE"
images/main/Dockerfile
Copy
FROM ghcr.io/build-trust/ockam-python:latest
COPY . .
ENTRYPOINT ["python", "main.py"]
images/main/main.py
Copy
from datetime import datetime
from ockam import Agent, Model, Node, McpTool, McpClient, Tool
def current_iso8601_utc_time():
"""
Returns the current UTC time in ISO 8601 format.
"""
return datetime.utcnow().isoformat() + "Z"
async def main(node):
await Agent.start(
node=node,
name="henry",
instructions="""
You are Henry, an expert legal assistant.
When you are given a question, decide if your response can be better
with a web search. If so, use the web search tool to improve your response.
""",
model=Model("claude-3-7-sonnet-v1"),
tools=[
McpTool("brave_search", "brave_web_search"),
Tool(current_iso8601_utc_time),
],
)
Node.start(
main,
mcp_clients=[
McpClient(name="brave_search", address="http://localhost:8001/sse"),
],
)
Copy
http POST \
"https://25df35de87aa441b88f22a6c2a830a17-example006.ai.ockam.network/agents/henry" \
message="Find links to cases currently in the US Supreme Court"
Assistant
Responses are generated using AI and may contain mistakes.