Building an Agent
MCP Integration
Model Context Protocol (MCP) lets agents connect to external services and data sources through a standardized interface. Configure a server with MCPConfig and pass it in mcp_servers.
from ncp import Agent, MCPConfig
filesystem_server = MCPConfig.stdio(
command="mcp-server-filesystem",
args=["/path/to/files"],
)
agent = Agent(
name="MultiServiceAgent",
description="Agent with MCP integrations",
instructions="...",
mcp_servers=[filesystem_server],
)Transport Types
MCP supports three transports. Construct each with its matching factory method:
from ncp import MCPConfig
# stdio - launch a local process, talk over stdin/stdout
stdio_server = MCPConfig.stdio(
command="mcp-server-filesystem",
args=["/path/to/files"],
env={"LOG_LEVEL": "info"}, # optional environment variables
cwd="/opt/mcp", # optional working directory
)
# sse - Server-Sent Events (URL-based)
sse_server = MCPConfig.sse(
url="https://api.example.com/mcp",
headers={"Authorization": "Bearer token"}, # optional
)
# streamable-http - HTTP streaming (URL-based)
http_server = MCPConfig.streamable_http(url="https://streaming-api.example.com/mcp")For stdio servers, the server executable and its dependencies must be installed in the agent's execution environment.
Restricting Exposed Tools
Every MCPConfig accepts an optional allowed_tools allowlist. When omitted, all of the server's tools are exposed; when set, only the listed tools are:
Multiple MCP Servers
Data Connector Integration
Agents can use data connectors configured on the platform - such as Splunk, ELK, NetBox, or BigQuery - by referencing them by name in connectors. Connector resolution and credentials are managed by the platform: the agent names the connector, the platform resolves access (subject to role-based permissions) and exposes the connector's capabilities to the agent, and your tool code never handles raw credentials.
Multiple connectors:
Use ncp connectors list / ncp connectors info <name> to see the connectors available on your platform (see SDK Workflow → Discovering Connectors and Platform Agents). For custom SSH or HTTP endpoints that do not have a dedicated connector, use the session APIs in your own tools (see Advanced Features → Generic SSH/HTTP Connectors).
Dependency Management
Pin exact versions in requirements.txt for reproducible builds:
Install them into your virtual environment during development:
Declare system packages (optional) in apt-requirements.txt:
If your project is structured as an installable package, an editable install (pip install -e .) is convenient during development where supported.
Last updated
