- Create custom tools that integrate with LangSmith’s Agent Auth for OAuth authentication
- Build an MCP gateway for agents you’re building yourself (outside of Agent Builder)
If you’re using Agent Builder, you don’t need to interact with the Tool Server directly. Agent Builder provides built-in tools and supports remote MCP servers without requiring Tool Server setup.However, you can configure the associated tool server instance as an MCP server, which will allow you to use your custom MCP servers in your agent.
Create a custom toolkit
Install the LangSmith Tool Server and LangChain CLI:@tool decorator:
http://localhost:8000.
Call tools via MCP protocol
Below is an example that lists available tools and calls theadd tool:
Use as an MCP gateway
The LangSmith Tool Server can act as an MCP gateway, aggregating tools from multiple MCP servers into a single endpoint. Configure MCP servers in yourtoolkit.toml:
/mcp endpoint. MCP tools are prefixed with their server name to avoid conflicts (e.g., weather_get_forecast, math_add).
Authenticate
OAuth for third-party APIs
For tools that need to access third-party APIs (like Google, GitHub, Slack, etc.), you can use OAuth authentication with Agent Auth. Before using OAuth in your tools, you’ll need to configure an OAuth provider in your LangSmith workspace settings. See the Agent Auth documentation for setup instructions. Once configured, specify theauth_provider in your tool decorator:
auth_provider must:
- Have
context: Contextas the first parameter - Specify at least one scope
- Use
context.tokento make authenticated API calls
Custom request authentication
Custom authentication allows you to validate requests and integrate with your identity provider. Define an authentication handler in yourauth.py file:
identity (and optionally permissions).