|
|
4 tuần trước cách đây | |
|---|---|---|
| .. | ||
| testdata | 1 tháng trước cách đây | |
| .env.example | 1 tháng trước cách đây | |
| README.md | 1 tháng trước cách đây | |
| agent.go | 1 tháng trước cách đây | |
| agent_test.go | 1 tháng trước cách đây | |
| arp_agent | 4 tuần trước cách đây | |
| config.go | 1 tháng trước cách đây | |
| config_test.go | 1 tháng trước cách đây | |
| go.mod | 1 tháng trước cách đây | |
| go.sum | 1 tháng trước cách đây | |
| llm.go | 1 tháng trước cách đây | |
| llm_test.go | 1 tháng trước cách đây | |
| main.go | 4 tuần trước cách đây | |
| mcp.json.example | 4 tuần trước cách đây | |
| mcp_client.go | 4 tuần trước cách đây | |
| mcp_config.go | 1 tháng trước cách đây | |
| mcp_manager.go | 4 tuần trước cách đây | |
| mcp_manager_test.go | 4 tuần trước cách đây | |
| mcp_stdio.go | 4 tuần trước cách đây | |
| testutil_test.go | 1 tháng trước cách đây | |
An LLM-powered agent that processes events from the ARP (Agent-native ERP) platform using the Model Context Protocol (MCP).
The ARP Agent is an intelligent agent that:
Clone and navigate to the agent:
cd arp_agent
Copy the example environment file:
cp .env.example .env
Edit .env with your configuration (see Configuration section below)
Build and run:
go build -o arp_agent
./arp_agent
The agent looks for configuration files in the following locations (in order of priority):
.env FileCopy .env.example to .env and configure:
# ARP Server Configuration (required)
ARP_URL=http://localhost:8080
ARP_USERNAME=mira@slang.com
ARP_PASSWORD=mira
# OpenAI API Configuration (required)
OPENAI_API_KEY=your-api-key-here
OPENAI_MODEL=openai/gpt-4
OPENAI_TEMPERATURE=0.5
OPENAI_MAX_TOKENS=4096
# OpenAI Base URL (optional - for local/custom LLMs)
# Default: https://api.openai.com/v1
OPENAI_BASE_URL=http://localhost:1234/v1
mcp.json FileFor external MCP servers, create a mcp.json file (copy from mcp.json.example):
{
"mcpServers": {
"brave-search": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
"env": {
"BRAVE_API_KEY": "your-api-key-here"
}
}
}
}
To use the MCP config file, set the environment variable:
MCP_CONFIG_PATH=/path/to/mcp.json
| Variable | Required | Default | Description |
|---|---|---|---|
ARP_URL |
Yes | - | ARP server URL (e.g., http://localhost:8080) |
ARP_USERNAME |
Yes | - | ARP login email |
ARP_PASSWORD |
Yes | - | ARP login password |
OPENAI_API_KEY |
Yes | - | OpenAI API key |
OPENAI_MODEL |
No | gpt-4 |
LLM model name |
OPENAI_TEMPERATURE |
No | 0.0 |
LLM temperature (0.0-2.0) |
OPENAI_MAX_TOKENS |
No | 4096 |
Max tokens for response |
OPENAI_BASE_URL |
No | OpenAI API | Base URL for LLM (supports local/custom endpoints) |
ARP_AGENT_NAME |
No | AI Assistant |
Agent's display name |
ARP_AGENT_SPECIALIZATION |
No | general assistance |
Agent's specialization |
ARP_AGENT_VALUES |
No | helpfulness, accuracy, and collaboration |
Agent's values |
ARP_AGENT_GOALS |
No | help teammates accomplish their goals |
Agent's goals |
ARP_MAX_QUEUE_SIZE |
No | 100 |
Maximum events to queue |
ARP_MAX_ITERATIONS |
No | 10 |
Max tool call iterations per event |
MCP_CONFIG_PATH |
No | - | Path to mcp.json |
# Build
go build -o arp_agent
# Run
./arp_agent
# Use custom .env location
cd /custom/path && ./arp_agent
# Or use absolute path for MCP config
MCP_CONFIG_PATH=/etc/arp/mcp.json ./arp_agent
FROM golang:1.25-alpine AS builder
WORKDIR /app
COPY . .
RUN go build -o arp_agent
FROM alpine:latest
COPY --from=builder /app/arp_agent .
COPY --from=builder /app/.env.example .env
RUN apk add --no-cache ca-certificates
ENTRYPOINT ["./arp_agent"]
The agent has a customizable identity that defines how it behaves on the platform:
# Example: HR Specialist
ARP_AGENT_NAME=HR Bot
ARP_AGENT_SPECIALIZATION=HR and people operations
ARP_AGENT_VALUES=empathy, privacy, and professionalism
ARP_AGENT_GOALS=help employees with HR questions and processes
# Example: Engineering Assistant
ARP_AGENT_NAME=Dev Assistant
ARP_AGENT_SPECIALIZATION=software development and DevOps
ARP_AGENT_VALUES=code quality, documentation, and continuous improvement
ARP_AGENT_GOALS=help developers ship reliable software efficiently
Important: The agent IS a user on the platform (not an assistant helping a user). When it creates tasks, notes, or messages, it does so as itself.
The agent has access to these ARP tools via MCP:
introspectDiscover the GraphQL schema structure.
# Get full schema
introspect()
# Get specific type
introspect(typeName: "Task")
# Get mutation fields
introspect(typeName: "Mutation")
queryExecute GraphQL queries (read operations).
query {
tasks(status: "open") {
id
title
assignee {
email
}
}
}
mutateExecute GraphQL mutations (create/update/delete operations).
# Create a task
mutation {
createTask(input: {
title: "Review PR"
content: "Please review PR #123"
priority: "high"
serviceId: "service-123"
}) {
id
title
}
}
# Update a task
mutation {
updateTask(id: "task-123", input: {
statusId: "status-done"
}) {
id
status {
label
}
}
}
Add external MCP servers to extend the agent's capabilities:
{
"mcpServers": {
"brave-search": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
"env": {
"BRAVE_API_KEY": "your-api-key"
}
}
}
}
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "your-github-token"
}
}
}
}
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/allowed/directory"]
}
}
}
External tools are prefixed with the server name (e.g., brave-search.search, github.list_pull_requests).
┌─────────────────────────────────────────────────────────────┐
│ ARP Agent │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌───────────────┐ │
│ │ LLM │ │ Agent │ │ MCP Manager │ │
│ │ (OpenAI) │◄───│ Processor │───►│ │ │
│ └─────────────┘ └─────────────┘ └───────┬───────┘ │
│ │ │
│ ┌──────────────────────────────────────────────┼────────┐ │
│ │ Event Queues │ │ │
│ │ ┌──────────────┐ ┌──────────────────┐ │ │ │
│ │ │ Task Events │ │ Message Events │ │ │ │
│ │ │ (taskCreated │ │ (messageAdded) │ │ │ │
│ │ │ taskUpdated │ │ │ │ │ │
│ │ │ taskDeleted)│ │ │ │ │ │
│ │ └──────────────┘ └──────────────────┘ │ │ │
│ └─────────────────────────────────────────────┴────────┘ │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ External MCP Servers │
├─────────────────────────────────────────────────────────────┤
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ brave-search │ │ github │ │ filesystem │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ ARP Server │
├─────────────────────────────────────────────────────────────┤
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ GraphQL │ │ MCP │ │ Database │ │
│ │ (query) │ │ (SSE) │ │ │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────┘
"Failed to connect to OpenAI API"
OPENAI_API_KEY is correctOPENAI_BASE_URL if using a custom endpoint"Failed to login"
ARP_URL, ARP_USERNAME, and ARP_PASSWORD are correct"Failed to connect to SSE"
"ARP_URL environment variable is required"
.env.example to .env and fill in the values"OPENAI_API_KEY environment variable is required"
.env fileExternal MCP server fails to start
mcp.jsonenv section"Unknown tool" errors
brave-search.search)mcp.json"Max iterations reached"
ARP_MAX_ITERATIONS in .env (default: 10)"Queue is full, dropping event"
ARP_MAX_QUEUE_SIZE in .env (default: 100)"Response truncated: model hit token limit"
OPENAI_MAX_TOKENS in .env (default: 4096)MIT