MCP Integration
Connect agents with external tools using Model Context Protocol.
Quick Start
Clone the Complete Example
The easiest way to get started is to clone the complete example repository:
git clone https://github.com/astreus-ai/mcp-integration
cd mcp-integration
npm install
Or Install Package Only
If you prefer to build from scratch:
npm install @astreus-ai/astreus
Environment Setup
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
GITHUB_PERSONAL_ACCESS_TOKEN=ghp_***
BRAVE_API_KEY=your-brave-api-key
DB_URL=sqlite://./astreus.db
MCP Server Integration
import { Agent } from '@astreus-ai/astreus';
// Create agent
const agent = await Agent.create({
name: 'DevAgent',
model: 'gpt-4o',
systemPrompt: 'You are a development assistant with access to GitHub and filesystem.'
});
// Add MCP servers (environment variables loaded automatically)
await agent.addMCPServers([
{
name: 'github',
command: "npx",
args: ["-y", "@modelcontextprotocol/server-github"]
// GITHUB_PERSONAL_ACCESS_TOKEN loaded from .env
},
{
name: 'filesystem',
command: "npx",
args: ["-y", "@modelcontextprotocol/server-filesystem", "/Users/username/Documents"]
}
]);
// Use MCP tools automatically
const response = await agent.ask(`
List my GitHub repositories,
find the most recent one,
and save a summary to a file called 'latest-repo.txt'
`);
console.log(response);
// Agent automatically uses GitHub API and filesystem tools
Running the Example
If you cloned the repository:
npm run dev
If you built from scratch, create an index.ts
file with the code above and run:
npx tsx index.ts
Repository
The complete example is available on GitHub: astreus-ai/mcp-integration
How is this guide?