mirror of
https://github.com/JackChen-me/open-multi-agent.git
synced 2026-10-19 01:29:57 -05:00
* docs(examples): prefix example run commands with packages/core/ Examples live under packages/core/, and both READMEs document running them from the repo root (npx tsx packages/core/examples/<path>.ts), but the in-file Run: headers and a few READMEs still used the bare examples/ path. The repo root has no top-level examples/, so copy-pasting those commands from root failed with file-not-found. Prefixes 67 run/cd commands across 56 files (53 example scripts + examples/README.md + two integration READMEs). Markdown links that use the bare examples/ path are correct relative links and are left unchanged. * docs: prefix two stale examples/ path references in docs/ context-management.md and tool-configuration.md referenced bare examples/ paths that do not resolve from the repo root. Make the first a relative link (matching the convention in model-routing.md) and prefix the second with packages/core/. Follow-up to the run-command fixes in this PR.
63 lines
1.6 KiB
TypeScript
63 lines
1.6 KiB
TypeScript
/**
|
|
* MCP GitHub Tools
|
|
*
|
|
* Connect an MCP server over stdio and register all exposed MCP tools as
|
|
* standard open-multi-agent tools.
|
|
*
|
|
* Run:
|
|
* npx tsx packages/core/examples/integrations/mcp-github.ts
|
|
*
|
|
* Prerequisites:
|
|
* - GEMINI_API_KEY
|
|
* - GITHUB_TOKEN
|
|
* - @modelcontextprotocol/sdk installed
|
|
* - @modelcontextprotocol/server-github installed locally
|
|
*/
|
|
|
|
import { Agent, ToolExecutor, ToolRegistry, registerBuiltInTools } from '../../src/index.js'
|
|
import { connectMCPTools } from '../../src/mcp.js'
|
|
|
|
if (!process.env.GITHUB_TOKEN?.trim()) {
|
|
console.error('Missing GITHUB_TOKEN: set a GitHub personal access token in the environment.')
|
|
process.exit(1)
|
|
}
|
|
|
|
const { tools, disconnect } = await connectMCPTools({
|
|
command: 'npx',
|
|
args: ['--no-install', '@modelcontextprotocol/server-github'],
|
|
env: {
|
|
GITHUB_TOKEN: process.env.GITHUB_TOKEN,
|
|
HOME: process.env.HOME,
|
|
PATH: process.env.PATH,
|
|
TMPDIR: process.env.TMPDIR,
|
|
},
|
|
namePrefix: 'github',
|
|
})
|
|
|
|
const registry = new ToolRegistry()
|
|
registerBuiltInTools(registry)
|
|
for (const tool of tools) registry.register(tool)
|
|
const executor = new ToolExecutor(registry)
|
|
|
|
const agent = new Agent(
|
|
{
|
|
name: 'github-agent',
|
|
model: 'gemini-2.5-flash',
|
|
provider: 'gemini',
|
|
tools: tools.map((tool) => tool.name),
|
|
systemPrompt: 'Use GitHub MCP tools to answer repository questions.',
|
|
},
|
|
registry,
|
|
executor,
|
|
)
|
|
|
|
try {
|
|
const result = await agent.run(
|
|
'List the last 3 open issues in open-multi-agent/open-multi-agent with title and number.',
|
|
)
|
|
|
|
console.log(result.output)
|
|
} finally {
|
|
await disconnect()
|
|
}
|