Skip to content

auxforge/openforge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OpenForge Banner

npm version License GitHub Stars Node.js


Build AI agents that use tools, connect to MCP servers, and work with any AI provider (OpenAI, Anthropic, Gemini, Groq, local models). Each agent is a portable JSON manifest that anyone can share, install, and run.

✨ Features

  • πŸ”Œ Full MCP Support β€” stdio, SSE, and WebSocket transports
  • πŸ”§ Built-in Tools β€” HTTP fetch, JSON parse, text transform, date/time
  • 🎨 Custom Tools β€” Write JS handlers, sandboxed via VM
  • πŸ€– Any AI Provider β€” Bring your own: OpenAI, Anthropic, Gemini, Ollama, anything
  • πŸ“¦ Portable Agents β€” JSON manifests that anyone can share and install
  • ⚑ Event Streaming β€” Real-time execution tracking via EventEmitter
  • πŸ–₯️ CLI Included β€” Create, run, and manage agents from the terminal

πŸš€ Quick Start

# Install globally
npm install -g openforge

# Create your first agent
openforge create my-agent "A helpful assistant"

# Run it (needs an API key)
OPENAI_API_KEY=sk-xxx openforge run my-agent "What's the weather in NYC?"

πŸ“¦ Programmatic Usage

const { AgentBuilder } = require('openforge');

const builder = new AgentBuilder({
  aiProvider: async (messages, model, tools) => {
    // Use any AI provider β€” OpenAI, Anthropic, Gemini, etc.
    const { OpenAI } = require('openai');
    const client = new OpenAI();
    return await client.chat.completions.create({
      model: model || 'gpt-4o-mini',
      messages,
      tools: tools?.length > 0 ? tools : undefined,
    });
  },
});

await builder.initialize();

// Run an agent
const result = await builder.runAgent('my-agent', 'Hello!');
console.log(result.output);

// Stream execution events
const { runtime, resultPromise } = await builder.runAgentStreaming('my-agent', 'Hello!');
runtime.on('tool_call', (data) => console.log(`πŸ”§ ${data.tool}`));
runtime.on('agent_response', (data) => console.log(`πŸ’¬ ${data.content}`));
const finalResult = await resultPromise;

await builder.shutdown();

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              OpenForge                    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ Runtime   β”‚ β”‚ Registry β”‚ β”‚  Loader  β”‚ β”‚
β”‚  β”‚(executor) β”‚ β”‚ (tools)  β”‚ β”‚ (agents) β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β”‚
β”‚        β”‚              β”‚           β”‚        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€       β”‚
β”‚  β”‚         Tool Registry          β”‚       β”‚
β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€       β”‚
β”‚  β”‚  MCP   β”‚Built-inβ”‚   Custom     β”‚       β”‚
β”‚  β”‚ Client β”‚ Tools  β”‚  JS/VM       β”‚       β”‚
β”‚  β””β”€β”€β”¬β”€β”€β”€β”€β”€β”˜β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
β””β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚
  MCP Servers (any!)
  - stdio (spawn local process)
  - SSE (HTTP streaming)
  - WebSocket (persistent)

πŸ“‹ Agent Manifest

Every agent is defined by a .agent.json file:

{
  "name": "my-agent",
  "version": "1.0.0",
  "description": "What this agent does",
  "systemPrompt": "You are a helpful assistant...",
  "runtime": {
    "model": "gpt-4o-mini",
    "maxLoops": 10,
    "timeoutMs": 60000
  },
  "tools": {
    "require": ["builtin:http_fetch", "builtin:json_parse"],
    "optional": ["mcp:calendar"]
  },
  "ui": {
    "icon": "πŸ€–"
  }
}

πŸ”Œ MCP Support

Full Model Context Protocol support β€” connect to any MCP server:

// stdio β€” spawn a local MCP server
await builder.addMcpServer('calculator', {
  transport: 'stdio',
  command: 'npx',
  args: ['-y', '@example/mcp-calculator'],
});

// SSE β€” connect to an HTTP MCP server
await builder.addMcpServer('api', {
  transport: 'sse',
  url: 'http://localhost:3001/sse',
});

// WebSocket β€” persistent connection
await builder.addMcpServer('realtime', {
  transport: 'websocket',
  url: 'ws://localhost:8080',
});

πŸ”§ Tool Providers

Provider Prefix Description
Built-in builtin: http_fetch, json_parse, text_transform, date_time, wait
MCP mcp: Any MCP-compliant server (stdio, SSE, WebSocket)
Custom custom: Agent-local JS handlers (sandboxed via VM)

🎨 Creating Custom Tools

Define custom tools in your agent manifest:

{
  "tools": {
    "custom": [
      {
        "name": "analyze_data",
        "description": "Analyze data from a CSV",
        "parameters": {
          "type": "object",
          "properties": {
            "data": { "type": "string" }
          }
        },
        "handler": "./tools/analyzeData.js"
      }
    ]
  }
}

Handler file (tools/analyzeData.js):

module.exports = async function(args, context) {
  const { data } = args;
  // Your analysis logic here
  return { success: true, result: 'Analysis complete' };
};

πŸ–₯️ CLI Reference

openforge list                          # List installed agents
openforge info <name>                   # Show agent details
openforge create <name> [description]   # Create from template
openforge run <name> <input>            # Run (needs OPENAI_API_KEY)
openforge tools                         # List available tools
openforge validate <path>               # Validate manifest

⚑ Event Streaming

The runtime emits events during execution for real-time tracking:

const { runtime, resultPromise } = await builder.runAgentStreaming('my-agent', input);

runtime.on('execution_started', (data) => { /* { id, agent } */ });
runtime.on('loop_iteration', (data) => { /* { id, loop, maxLoops } */ });
runtime.on('tool_call', (data) => { /* { id, tool, args } */ });
runtime.on('tool_result', (data) => { /* { id, tool, result } */ });
runtime.on('agent_response', (data) => { /* { id, content } */ });
runtime.on('execution_completed', (data) => { /* { id, agent, duration, loops } */ });

const result = await resultPromise;

πŸ“– API Reference

new AgentBuilder(options)

Option Type Required Description
aiProvider Function βœ… async (messages, model, tools, meta) => OpenAI-format response
agentDir string Custom agent directory (default: ~/.openforge/agents/)
mcpServers Object Initial MCP server configs
additionalAgentDirs string[] Extra directories to scan for agents

Methods

Method Returns Description
initialize() Promise Must be called before any operations
runAgent(name, input, ctx) Promise<Result> Run an agent synchronously
runAgentStreaming(name, input, ctx) { runtime, resultPromise } Run with event streaming
createAgent(config) AgentManifest Create a new agent
deleteAgent(name) boolean Delete an agent
listAgents(filter) Agent[] List all agents
addMcpServer(name, config) Promise<Server> Connect MCP server
removeMcpServer(name) Promise Disconnect MCP server
listTools() Tool[] List all available tools
shutdown() Promise Graceful shutdown

🀝 Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

πŸ“„ License

MIT β€” build whatever you want.

About

πŸ”₯ Open-source AI Agent Builder β€” Create, share, and run AI agents with MCP, tool-calling, and any AI provider (OpenAI, Anthropic, Gemini, Ollama)

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors