5 Ways to Connect AI Agents to Tools: From APIs to MCP
Grant Miller outlines five evolving patterns for integrating AI agents with tools, starting from simple direct API connections to complex, secure token-based architectures. The discussion highlights the progression of these methods, emphasizing how authentication, user delegation, abstraction layers like MCP, and secure credential management using vaults improve security, observability, and scalability in agentic systems.
This video details five evolving patterns for connecting AI agents to tools, emphasizing a progression towards enhanced security, control, and scalability in enterprise processes. Grant Miller outlines these patterns, each addressing limitations of the previous.
Pattern 5: Direct Connection
This initial, straightforward pattern involves a user interacting with an agent, which then directly connects to a tool using its own credentials (e.g., API keys, service IDs). This model was common in early Gen AI and RAG systems.
- Pros: Simple to implement, utilizes existing connection methods.
- Cons: Lack of user visibility at the tool level; the tool only sees the agent’s credentials, not the end-user. This often limited use to publicly available or company-wide accessible information.
Pattern 4: Direct Connection with OAuth Flows
Building on Pattern 5, this introduces OAuth flows and an identity provider for user authentication. The agent initiates interaction, the tool authenticates the user via OAuth, and issues an access token to the agent. This token is then used for subsequent tool interactions, allowing the agent to act “on behalf of” the user. Examples include integrations with GitHub, Jira, and Slack, and applications like Claude.
- Pros: Leverages established and secure OAuth patterns; authenticates the user, addressing the visibility issue of Pattern 5.
- Cons: The agent impersonates the user, meaning the tool has no visibility into the agent itself or its actions. This pattern also introduces long-lived credentials, as access tokens can persist for extended periods (e.g., 90 days), posing a security risk if compromised.
Pattern 3: Adding Model Context Protocol (MCP)
This pattern integrates an MCP layer between the agent and the tool, while largely retaining the OAuth flows for authentication. The key innovation here is an abstraction layer.
- Pros: The agent no longer needs specific knowledge of each tool’s API or interaction methods. It only needs to understand how to interact with the MCP, simplifying agent development and increasing flexibility for integrating multiple tools.
- Cons: While improving abstraction, this pattern still carries the risk of long-lived credentials inherited from Pattern 4.
Pattern 2: On Behalf Of / Token Exchange
Moving beyond direct OAuth for agent-tool interaction, this pattern focuses on delegation and secure token exchange. It requires the agent to authenticate itself, and then operate “on behalf of” the user, who explicitly delegates work. A token exchange mechanism secures the flow of tokens.
- Pros: Authenticates both the user and the agent, providing full transparency and observability (the system knows both who the user is and what the agent is doing). It eliminates impersonation, as the tool is aware of both entities and their authorized actions.
- Cons: Although the token flow is secured, it still implies the use of a user’s access token that might be long-lived, which is a potential vulnerability.
Pattern 1: Integrating a Vault
This top pattern introduces a vault to manage credentials, addressing the critical issue of long-lived tokens from previous patterns. Instead of storing a long-term user token with the agent or in the MCP, it’s securely stored in a vault. The vault then issues short-lived credentials to the MCP for specific agent operations.
- Pros: Significantly enhances security by using only short-lived credentials for agent-tool interactions. If a token is intercepted, its limited lifespan minimizes the risk of replay attacks or unauthorized access.
- Cons: Increases architectural complexity due to the introduction of a dedicated vault service.
In summary, these patterns demonstrate a clear evolution from basic connectivity to sophisticated, secure, and observable agentic systems, with each step improving upon the security and management of credentials and interactions.