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.

BehaviorWhat determines it
Source freshnessThe source API, provider backend, and caching
Links and citationsThe provider's returned documents and the agent's response
Accessible recordsThe 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.

NeedMode
Provider-recommended tool surfaceContextMode.default
One natural-language query tool backed by a sub-agentContextMode.agent
Direct control over provider operationsContextMode.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

SourceToolsBacked by
Webquery_webExa, Parallel, or an MCP search backend
Filesystemquery_fsA local directory of files, read-only
Workspacequery_workspaceA filesystem path or repo, read-only
Databasequery_database, update_databaseSQLAlchemy read and write engines
Knowledge wikiquery_wiki, update_wikiFilesystem, a Git repo, or Notion for durable prose memory
Slackquery_slack, update_slackSlack API, reads and writes
Google Drivequery_gdriveA service account or OAuth credentials, read-only
Gmailquery_gmail, update_gmailGmail API with Google credentials; writes are off by default
Google Calendarquery_calendar, update_calendarGoogle Calendar API; writes are off by default
MCP serversquery_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

TaskGuide
Reach users where they workInterfaces
Persist what the agent learnsSessions and memory

Developer Resources