Using MCP Tools in RailTracks
Overview
Quick Summary
RailTracks makes it easy to use any MCP-compatible tool with your agents. Just connect to an MCP server, get the tools, and start using them!
RailTracks supports seamless integration with Model Context Protocol (MCP), allowing you to use any MCP-compatible tool as a native RailTracks Tool. This means you can connect your agents to a wide variety of external tools and data sources—without having to implement the tool logic yourself.
RailTracks handles the discovery and invocation of MCP tools, so you can focus on building intelligent agents.
Prerequisites
Before You Begin
Make sure you have the following set up before using MCP tools:
- RailTracks Framework installed (
pip install railtracks[core]
) - MCP package set up - Every MCP tool has different requirements (see specific tool documentation)
- Authentication credentials - Many MCP tools require API keys or OAuth tokens
Connecting to MCP Server Types
RailTracks supports two types of MCP servers
Remote HTTP Servers
Use MCPHttpParams
for connecting to remote MCP servers:
Local Stdio Servers
Use MCPStdioParams
for running local MCP servers:
Using MCP Tools with RailTracks Agents
Once you've connected to an MCP server, you can use the tools with your RailTracks agents:
import railtracks as rt
# Run a local MCP server (Time server example)
time_server = rt.connect_mcp(
rt.MCPStdioParams(
command="npx",
args=["mcp-server-time"] # or other command to run the server
)
)
Common MCP Server Examples
Fetch Server (URL Content Retrieval)
Guide: Websearch ServerGitHub Server
github_server = rt.connect_mcp(
rt.MCPHttpParams(
url="https://api.githubcopilot.com/mcp/",
headers={
"Authorization": f"Bearer {'<GITHUB_PAT_TOKEN>'}",
},
)
)
Guide: Github Server
Notion Server
import json
notion_server = rt.connect_mcp(
rt.MCPStdioParams(
command="npx",
args=["-y", "@notionhq/notion-mcp-server"],
env={
"OPENAPI_MCP_HEADERS": json.dumps({
"Authorization": f"Bearer {'<NOTION_API_TOKEN>'}",
"Notion-Version": "2022-06-28"
})
},
)
)
Combining Multiple MCP Tools
You can combine tools from different MCP's into one single agent.
# You can combine the tools from multiple MCP servers
all_tools = notion_server.tools + github_server.tools + fetch_server.tools
# Create an agent that can use all tools
super_agent = rt.agent_node(
tool_nodes=all_tools,
name="Multi-Tool Agent",
system_message="Use the appropriate tools to complete tasks.",
llm=rt.llm.OpenAILLM("gpt-4o"),
)
Tool-Specific Guides
For detailed setup and usage instructions for specific MCP tools: