
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
@aigne/example-afs-mcp-server
Advanced tools
A demonstration of using AIGNE Framework with AFS mount a MCP server
This example shows how to mount any MCP (Model Context Protocol) server as an AFS module, making it accessible to AI agents through a unified file system interface. We use the GitHub MCP Server as a real-world demonstration.
User asks: "Search for a repo named aigne"
Behind the scenes:
afs_exec â /modules/github-mcp-server/search_repositoriesThe power: AI agents can access GitHub (or any MCP server) through a simple, unified AFS interface - just like accessing files!
# Set your GitHub Personal Access Token
export GITHUB_PERSONAL_ACCESS_TOKEN=your_github_token_here
# Set your OpenAI API key
export OPENAI_API_KEY=your_openai_api_key_here
# Run in interactive chat mode
npx -y @aigne/example-afs-mcp-server --chat
# Ask a specific question
npx -y @aigne/example-afs-mcp-server --input "Search for a repo named aigne"
Here's what happens when you ask to search for a repository:
đ¤ You: "Search for a repo named aigne"
đ¤ Agent thinks: I need to search GitHub repositories...
â Calls: afs_exec("/modules/github-mcp-server/search_repositories")
đĄ GitHub MCP Server:
â Found 89 repositories matching "aigne"
đ¤ AI: "I searched GitHub for 'aigne'. Results: 89 repositories found.
Notable matches:
⢠aigne-framework (AIGNE-io/aigne-framework) - â 150 stars
⢠aigne-examples (user/aigne-examples) - â 12 stars
...
Would you like me to open any of these repos or see more details?"
Key insight: The agent treats the GitHub MCP Server like any other AFS module - no special integration code needed!
git clone https://github.com/AIGNE-io/aigne-framework
cd aigne-framework/examples/afs-mcp-server
pnpm install
Setup your API keys in the .env.local file:
GITHUB_PERSONAL_ACCESS_TOKEN="" # Set your GitHub Personal Access Token here
OPENAI_API_KEY="" # Set your OpenAI API key here
You can use different AI models by setting the MODEL environment variable along with the corresponding API key. The framework supports multiple providers:
MODEL="openai:gpt-4.1" with OPENAI_API_KEYMODEL="anthropic:claude-3-7-sonnet-latest" with ANTHROPIC_API_KEYMODEL="gemini:gemini-2.0-flash" with GEMINI_API_KEYMODEL="bedrock:us.amazon.nova-premier-v1:0" with AWS credentialsMODEL="deepseek:deepseek-chat" with DEEPSEEK_API_KEYMODEL="openrouter:openai/gpt-4o" with OPEN_ROUTER_API_KEYMODEL="xai:grok-2-latest" with XAI_API_KEYMODEL="ollama:llama3.2" with OLLAMA_DEFAULT_BASE_URLFor detailed configuration examples, please refer to the .env.local.example file in this directory.
# Run in interactive chat mode
pnpm start --chat
# Run with a single message
pnpm start --input "What are the recent issues in the AIGNE repository?"
import { MCPAgent } from "@aigne/core";
const mcpAgent = await MCPAgent.from({
command: "docker",
args: [
"run", "-i", "--rm",
"-e", `GITHUB_PERSONAL_ACCESS_TOKEN=${process.env.GITHUB_PERSONAL_ACCESS_TOKEN}`,
"ghcr.io/github/github-mcp-server",
],
});
import { AFS } from "@aigne/afs";
import { AFSHistory } from "@aigne/afs-history";
const afs = new AFS()
.mount(new AFSHistory({ storage: { url: ":memory:" } }))
.mount(mcpAgent); // Mounted at /modules/github-mcp-server
import { AIAgent } from "@aigne/core";
const agent = AIAgent.from({
instructions: "Help users interact with GitHub via the github-mcp-server module.",
inputKey: "message",
afs, // Agent automatically gets access to all mounted modules
});
That's it! The agent can now call /modules/github-mcp-server/search_repositories, /modules/github-mcp-server/list_issues, and all other GitHub MCP tools through the AFS interface.
# Search for repositories
npx -y @aigne/example-afs-mcp-server --input "Search for a repo named aigne"
# Get repository information
npx -y @aigne/example-afs-mcp-server --input "Tell me about the AIGNE-io/aigne-framework repository"
# Check recent issues
npx -y @aigne/example-afs-mcp-server --input "What are the recent open issues in AIGNE-io/aigne-framework?"
# Interactive mode - ask follow-up questions naturally
npx -y @aigne/example-afs-mcp-server --chat
In chat mode, try:
The Problem: Each MCP server has its own protocol and tools. AI agents need custom code to work with each one.
The Solution: Mount all MCP servers as AFS modules:
const afs = new AFS()
.mount("/github", await MCPAgent.from({ /* GitHub MCP */ }))
.mount("/slack", await MCPAgent.from({ /* Slack MCP */ }))
.mount("/notion", await MCPAgent.from({ /* Notion MCP */ }));
// Now the agent uses ONE interface (afs_exec) to access ALL services!
Benefits:
afs_list, afs_read, afs_execReplace GitHub with any MCP server:
// Slack MCP Server
.mount(await MCPAgent.from({
command: "npx",
args: ["-y", "@modelcontextprotocol/server-slack"],
env: { SLACK_BOT_TOKEN: process.env.SLACK_BOT_TOKEN },
}))
// File System MCP Server
.mount(await MCPAgent.from({
command: "npx",
args: ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/files"],
}))
// Postgres MCP Server
.mount(await MCPAgent.from({
command: "npx",
args: ["-y", "@modelcontextprotocol/server-postgres"],
env: { POSTGRES_CONNECTION_STRING: process.env.DATABASE_URL },
}))
import { LocalFS } from "@aigne/afs-local-fs";
import { UserProfileMemory } from "@aigne/afs-user-profile-memory";
const afs = new AFS()
.mount(new AFSHistory({ storage: { url: ":memory:" } }))
.mount(new LocalFS({ localPath: "./docs" }))
.mount(new UserProfileMemory({ context }))
.mount(await MCPAgent.from({ /* GitHub MCP */ }))
.mount(await MCPAgent.from({ /* Slack MCP */ }));
// Agent now has: history, local files, user profiles, GitHub, Slack!
This package includes full TypeScript type definitions.
FAQs
A demonstration of using AIGNE Framework with AFS mount a MCP server
We found that @aigne/example-afs-mcp-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rustâs crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.