Register a function with AgentRPC to make it available to AI agents
Start the Model Context Protocol server to expose registered functions
AgentRPC provides a universal RPC interface that allows AI agents to connect to any function, in any language, across network boundaries. It's designed for scenarios where services are deployed in private VPCs, Kubernetes clusters, or multiple cloud environments. The platform wraps functions in a standardized interface accessible through open standards like Model Context Protocol (MCP) and OpenAI-compatible tool definitions.
AgentRPC is a powerful tool that creates a universal RPC layer for AI agents, allowing them to connect to functions across different programming languages and network boundaries. This makes it ideal for organizations with services deployed in private VPCs, Kubernetes clusters, or multiple cloud environments.
To get started with AgentRPC, you'll need to install the appropriate SDK for your programming language:
npm install agentrpc
pip install agentrpc
go get github.com/agentrpc/agentrpc/sdk-go
AgentRPC requires an API secret for authentication. You can set this as an environment variable:
export AGENTRPC_API_SECRET=your_api_secret
Use the SDK to register your functions with AgentRPC. Here's a basic example in TypeScript:
import { registerFunction } from 'agentrpc';
// Register a simple function
registerFunction({
name: 'getWeather',
description: 'Get the current weather for a location',
parameters: {
location: {
type: 'string',
description: 'The city and state, e.g. San Francisco, CA',
},
},
handler: async ({ location }) => {
// Your implementation here
return { temperature: 72, conditions: 'sunny' };
},
});
Similar patterns are available in Python and Go.
To make your registered functions available to AI agents via the Model Context Protocol, start the MCP server:
AGENTRPC_API_SECRET=your_api_secret npx agentrpc mcp
This launches an MCP-compliant server that external AI models can interact with.
AgentRPC supports functions that run beyond typical HTTP timeout limits through long polling:
registerFunction({
name: 'processLargeDataset',
// ... parameter definitions
handler: async (params) => {
// This can run for minutes or hours
const result = await longRunningProcess(params);
return result;
},
});
AgentRPC provides comprehensive tracing and metrics. You can enable detailed logging:
import { setLogLevel } from 'agentrpc';
// Set log level to debug for more detailed information
setLogLevel('debug');
The platform automatically monitors the health of your registered functions and provides automatic failover and retries when issues are detected.
For more detailed examples, refer to the examples directory in the GitHub repository, which contains working code samples in multiple languages.