Connecting your data
Give agents access to external sources using context providers.
Customer-facing agents that work with live business state need current records and product actions. Context providers connect them to sources such as web search, files, databases, Slack, Google Drive, and MCP servers.
In default mode, context providers expose a source through query_<source> and, where enabled, update_<source>. The query surface can delegate source-specific work to a sub-agent. Set mode=ContextMode.tools when the calling agent should receive the provider's underlying tools directly.
uv pip install "agno[openai,exa]"
export OPENAI_API_KEY="..."
export EXA_API_KEY="..."import asyncio
from agno.agent import Agent
from agno.context.web import ExaBackend, WebContextProvider
from agno.models.openai import OpenAIResponses
async def main() -> None:
web = WebContextProvider(backend=ExaBackend(), model=OpenAIResponses(id="gpt-5.5"))
await web.asetup()
try:
agent = Agent(
model=OpenAIResponses(id="gpt-5.5"),
tools=web.get_tools(),
instructions=web.instructions() + "\nAlways cite URLs inline.",
)
await agent.aprint_response("What's the latest pricing for Anthropic's models?")
finally:
await web.aclose()
if __name__ == "__main__":
asyncio.run(main())The provider's query_web tool is async, so run this agent with arun() or aprint_response().
Query sources at run time
Context providers call the configured source when the agent invokes their tools. Freshness depends on the source API, backend, and any caching it applies. Providers can return source URIs or synthesized text; links and citations depend on the provider and its output.
Vector retrieval remains useful for indexed corpora. Context providers are useful when a task needs source-specific navigation or current records from an external system.
| Behavior | What determines it |
|---|---|
| Source freshness | The source API, provider backend, and caching |
| Links and citations | The provider's returned documents and the agent's response |
| Accessible records | The permissions granted to the provider's credentials |
Provider modes
Each provider ships a recommended tool surface. Override mode to trade tool count against direct control.
| Need | Mode |
|---|---|
| Provider-recommended tool surface | ContextMode.default |
| One natural-language query tool backed by a sub-agent | ContextMode.agent |
| Direct control over provider operations | ContextMode.tools exposes the underlying tools |
from agno.context import ContextMode
from agno.context.web import ExaBackend, WebContextProvider
web = WebContextProvider(backend=ExaBackend(), mode=ContextMode.tools)Sources
| Source | Tools | Backed by |
|---|---|---|
| Web | query_web | Exa, Parallel, or an MCP search backend |
| Filesystem | query_fs | A local directory of files, read-only |
| Workspace | query_workspace | A filesystem path or repo, read-only |
| Database | query_database, update_database | SQLAlchemy read and write engines |
| Knowledge wiki | query_wiki, update_wiki | Filesystem, a Git repo, or Notion for durable prose memory |
| Slack | query_slack, update_slack | Slack API, reads and writes |
| Google Drive | query_gdrive | A service account or OAuth credentials, read-only |
| Gmail | query_gmail, update_gmail | Gmail API with Google credentials; writes are off by default |
| Google Calendar | query_calendar, update_calendar | Google Calendar API; writes are off by default |
| MCP servers | query_mcp_<slug> | Any MCP server: Linear, GitHub, Notion |
Read-only providers
For providers that support writes, write=False removes the update tool from the default surface. A read-only provider such as the web has no update tool. This setting does not change permissions for other clients or integrations that can access the same source.
Next steps
| Task | Guide |
|---|---|
| Reach users where they work | Interfaces |
| Persist what the agent learns | Sessions and memory |