1. Get an API Key
Generate an API key
Once logged in, navigate to Cluster Settings > API Keys section and create a new API key.
Copy your API key
Copy your API key to use in the next steps. Keep this key secure as it provides access to your AgentRPC account.
Choose your preferred language to register a tool with AgentRPC:
import { AgentRPC } from 'agentrpc';
import { z } from 'zod';
const rpc = new AgentRPC({
apiSecret: process.env.AGENTRPC_API_SECRET!,
});
rpc.register({
name: 'getWeather',
description: 'Return weather information at a given location',
schema: z.object({ location: z.string() }),
handler: async ({ location }) => {
return {
location: location,
temperature: 'variable',
parcipitation: 'probably',
};
},
});
rpc.listen();
import { AgentRPC } from 'agentrpc';
import { z } from 'zod';
const rpc = new AgentRPC({
apiSecret: process.env.AGENTRPC_API_SECRET!,
});
rpc.register({
name: 'getWeather',
description: 'Return weather information at a given location',
schema: z.object({ location: z.string() }),
handler: async ({ location }) => {
return {
location: location,
temperature: 'variable',
parcipitation: 'probably',
};
},
});
rpc.listen();
package main
import (
"os"
"os/signal"
"syscall"
"github.com/agentrpc/agentrpc/sdk-go"
)
func main() {
rpc, _ := agentrpc.New(agentrpc.Options{
APISecret: os.Getenv("AGENTRPC_API_SECRET"),
})
rpc.Register(agentrpc.Tool{
Name: "getWeather",
Description: "Return weather information at a given location",
Handler: func(input struct{ Location string }) string {
return "probably raining"
},
})
go func() {
rpc.Listen()
}()
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
<-sigChan
defer rpc.Unlisten()
}
For more detailed examples, check out the SDK repositories:
3. Connect to an Agent
import { OpenAI } from 'openai';
import { AgentRPC } from 'agentrpc';
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const rpc = new AgentRPC({ apiSecret: process.env.AGENTRPC_API_SECRET });
const main = async () => {
const tools = await rpc.OpenAI.getTools();
const completion = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [
{
role: 'user',
content: 'What is the weather in Melbourne?',
},
],
tools,
});
const message = completion.choices[0]?.message;
if (message?.tool_calls) {
for (const toolCall of message.tool_calls) {
console.log('Agent is calling Tool', toolCall.function.name);
const result = await rpc.OpenAI.executeTool(toolCall);
console.log(result);
}
}
};
main();
import { OpenAI } from 'openai';
import { AgentRPC } from 'agentrpc';
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const rpc = new AgentRPC({ apiSecret: process.env.AGENTRPC_API_SECRET });
const main = async () => {
const tools = await rpc.OpenAI.getTools();
const completion = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [
{
role: 'user',
content: 'What is the weather in Melbourne?',
},
],
tools,
});
const message = completion.choices[0]?.message;
if (message?.tool_calls) {
for (const toolCall of message.tool_calls) {
console.log('Agent is calling Tool', toolCall.function.name);
const result = await rpc.OpenAI.executeTool(toolCall);
console.log(result);
}
}
};
main();
import asyncio
import os
from agentrpc import AgentRPC
from agents import Agent, Runner
async def main():
agentrpc = AgentRPC(api_secret=os.environ.get("AGENTRPC_API_SECRET", ""))
agent = Agent(name="AgentRPC Agent", tools=agentrpc.openai.agents.get_tools())
result = await Runner.run(
agent,
input="What is the weather in Melbourne?",
)
print(result.final_output)
if __name__ == "__main__":
asyncio.run(main())
Add the following to your claude_desktop_config.json
:
{
"mcpServers": {
"agentrpc": {
"command": "npx",
"args": ["-y", "agentrpc", "mcp"],
"env": {
"AGENTRPC_API_SECRET": "<YOUR_API_SECRET>"
}
}
}
}
More details
Add the following to your ~/.cursor/mcp.json
:
{
"mcpServers": {
"agentrpc": {
"command": "npx",
"args": ["-y", "agentrpc", "mcp"],
"env": {
"AGENTRPC_API_SECRET": "<YOUR_API_SECRET>"
}
}
}
}
More details
Navigate to the AgentRPC Dashboard to monitor tool usage, health, and performance.
Responses are generated using AI and may contain mistakes.