Skip to main content
Glama

AI Context MCP Server

A standalone MCP (Model Context Protocol) server that provides AI context orchestration for any project with a .ai-context folder. This server runs independently and can be used by multiple projects without installation via npx.

Quick Start

IMPORTANT: The AI_CONTEXT_ROOT environment variable is required and must point to your .ai-context folder.

Cursor (.cursor/mcp.json):

{
  "mcpServers": {
    "ai-context": {
      "command": "npx",
      "args": ["--yes", "github:alonlevyshavit/ai-context-mcp"],
      "env": {
        "AI_CONTEXT_ROOT": "/absolute/path/to/your/project/.ai-context"
      }
    }
  }
}

Claude Desktop:

{
  "mcpServers": {
    "ai-context": {
      "command": "npx",
      "args": ["--yes", "github:alonlevyshavit/ai-context-mcp"],
      "env": {
        "AI_CONTEXT_ROOT": "/absolute/path/to/your/project/.ai-context"
      }
    }
  }
}

The server will:

  1. Download automatically from GitHub

  2. Build itself if needed

  3. Use your specified .ai-context folder

  4. Provide tools for loading agents, guidelines, and frameworks

Related MCP server: Modular MCP Server

How It Works

Discovery-First Approach

The server embeds system instructions that guide AI assistants to:

  1. Discover available resources first using list_all_resources

  2. Read tool descriptions to understand each resource's purpose

  3. Select appropriate tools based on the task at hand

  4. Load resources strategically - single or multiple as needed

This ensures AI assistants adapt to your specific .ai-context structure rather than assuming certain agents exist.

Dynamic Tool Generation

The server automatically scans your .ai-context folder and creates specific MCP tools for each resource:

.ai-context/agents/planner.md → load_planner_agent tool
.ai-context/guidelines/api-design.md → load_guideline_api_design tool
.ai-context/frameworks/memory/README.md → load_framework_memory tool

Each tool includes rich metadata extracted from the resource files to help AI assistants make informed decisions about when to use them.

Multi-Format Metadata Support

The server supports multiple metadata formats with graceful fallbacks:

YAML Frontmatter (Preferred): img.png```markdown

description: Planning specialist for task breakdown and project organization use_cases:

  • Breaking down complex tasks into smaller steps

  • Creating project roadmaps

  • Organizing work into manageable chunks


Planner Agent

[content...]


**HTML Comments:**
```markdown
<!-- metadata
description: Planning specialist for task breakdown and project organization
use_cases: Task breakdown; Project roadmaps; Work organization
-->
# Planner Agent
[content...]

Natural Language Fallback:

# Planner Agent

You are a planning specialist focused on breaking down complex tasks into manageable steps. You excel at creating structured roadmaps and organizing work efficiently.
[content...]

Configuration for Cursor

Create a .cursor/mcp.json file in your project root:

{
  "mcpServers": {
    "ai-context": {
      "command": "npx",
      "args": ["--yes", "github:alonlevyshavit/ai-context-mcp"],
      "env": {
        "AI_CONTEXT_ROOT": "/absolute/path/to/your/project/.ai-context"
      }
    }
  }
}

Note: Replace /absolute/path/to/your/project/.ai-context with the actual absolute path to your .ai-context folder.

Required Configuration

The AI_CONTEXT_ROOT environment variable must be set to the absolute path of your .ai-context folder.

This explicit configuration ensures:

  • Clear and predictable behavior

  • No ambiguity about which .ai-context folder is being used

  • Consistent operation across different environments

  • Explicit control over the context being loaded

Project Structure

your-project/
├── .ai-context/              # Your AI context directory
│   ├── agents/              # Agent definitions (.md files)
│   ├── guidelines/          # Guidelines (.md files, can be nested)
│   └── frameworks/          # Framework folders with README.md
├── .cursor/
│   └── mcp.json            # MCP server configuration
└── [your project files...]

Available Tools

The server provides both dynamic and static tools:

Dynamic Tools (Generated from Content)

  • load_[name]_agent - Load a specific agent (e.g., load_debugger_agent, load_planner_agent)

  • load_guideline_[path] - Load a specific guideline

  • load_framework_[name] - Load a framework's documentation

Static Tools (Always Available)

  • list_all_resources - Lists all discovered agents, guidelines, and frameworks

  • load_multiple_resources - Load multiple resources simultaneously

Configuration Options

Required: AI_CONTEXT_ROOT Path

{
  "mcpServers": {
    "ai-context": {
      "command": "npx",
      "args": ["--yes", "github:alonlevyshavit/ai-context-mcp"],
      "env": {
        "AI_CONTEXT_ROOT": "/absolute/path/to/.ai-context"
      }
    }
  }
}

Selective Resource Loading

Control which types of resources are loaded as tools by setting environment variables.

Default behavior:

  • Agents: Always loaded (cannot be disabled)

  • Guidelines: Disabled by default (opt-in with AI_CONTEXT_LOAD_GUIDELINES="true")

  • Frameworks: Disabled by default (opt-in with AI_CONTEXT_LOAD_FRAMEWORKS="true")

{
  "mcpServers": {
    "ai-context": {
      "command": "npx",
      "args": ["--yes", "github:alonlevyshavit/ai-context-mcp"],
      "env": {
        "AI_CONTEXT_ROOT": "/absolute/path/to/.ai-context"
        // Agents are always loaded
        // Guidelines and frameworks are disabled by default
      }
    }
  }
}

Examples:

Load agents only (default behavior):

"env": {
  "AI_CONTEXT_ROOT": "/absolute/path/to/.ai-context"
}

Load agents and guidelines:

"env": {
  "AI_CONTEXT_ROOT": "/absolute/path/to/.ai-context",
  "AI_CONTEXT_LOAD_GUIDELINES": "true"
}

Load all resources (agents, guidelines, and frameworks):

"env": {
  "AI_CONTEXT_ROOT": "/absolute/path/to/.ai-context",
  "AI_CONTEXT_LOAD_GUIDELINES": "true",
  "AI_CONTEXT_LOAD_FRAMEWORKS": "true"
}

Specific Version/Branch

{
  "mcpServers": {
    "ai-context": {
      "command": "npx",
      "args": ["github:your-org/ai-context-mcp#v1.0.0"]
    }
  }
}

Development

Setup

git clone https://github.com/your-org/ai-context-mcp.git
cd ai-context-mcp
npm install

Commands

npm run build           # Build TypeScript to JavaScript
npm run dev            # Run in development mode
npm run test           # Run tests
npm run test:coverage  # Run tests with coverage
npm run typecheck      # TypeScript type checking
npm run validate       # Validate .ai-context metadata

Testing with Local Project

AI_CONTEXT_ROOT=/path/to/test-project/.ai-context npm run dev

Architecture

The server is built with:

  • TypeScript with ES2022/Node16 modules

  • MCP SDK for protocol communication

  • Vitest for comprehensive testing (98%+ coverage)

  • Dynamic tool generation from file system scanning

  • Enum-based constants for maintainable code

  • Comprehensive error handling and logging

Key components:

  • Scanner - Discovers and extracts metadata from resources

  • Loader - Loads content and assembles contexts

  • MetadataExtractor - Multi-format metadata extraction with fallbacks

  • AiContextMCPServer - Main MCP server with dynamic tool generation

License

MIT - See LICENSE file for details

Contributing

  1. Fork the repository

  2. Create a feature branch

  3. Make your changes with tests

  4. Run npm run test:run && npm run typecheck

  5. Submit a pull request

The dist/ folder must be committed for npx github: compatibility.

Available Tools

2 tools
list_all_resourcesA

Lists all available agents, guidelines, and frameworks in the system with their metadata

Inputs: no named parameters.

load_multiple_resourcesB

Load multiple resources (agents, guidelines, or frameworks) simultaneously for complex tasks.

    Specify resources with prefixes:
    - agent: for agents (e.g., "agent:planner")
    - guideline: for guidelines (e.g., "guideline:development/api-design")
    - framework: for frameworks (e.g., "framework:structured-memory")

    Example: ["agent:planner", "agent:codebase", "guideline:testing/unit-testing"]

Inputs: resources (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct roles: one discovers all available resources, while the other loads selected resources. There is no meaningful overlap that would cause misselection.

    Naming Consistency5/5

    Both names use consistent snake_case with a verb-based pattern: list_all_resources and load_multiple_resources. The shared resource-oriented suffix makes the set predictable and readable.

    Tool Count4/5

    Two tools are minimal but reasonable for a context-resource server focused on discovery and retrieval. The surface is slightly thin because there is no dedicated single-resource getter or search tool, but it is not badly scoped.

    Completeness4/5

    The set covers listing available agents/guidelines/frameworks and loading multiple resources for complex tasks. Minor gaps exist around single-resource loading and search/filtering, though load_multiple_resources can handle one item if needed.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      An MCP server implementation that standardizes how AI applications access tools and context, providing a central hub that manages tool discovery, execution, and context management with a simplified configuration system.
      13
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      A scalable, auto-discovering Model Context Protocol server that dynamically loads tools from the tools directory, enabling LLMs to access various capabilities through a standardized interface.
      -
    • A
      license
      C
      quality
      D
      maintenance
      A lightweight and extendable MCP server toolkit that allows developers to build and integrate custom tools with AI assistants through automatic tool discovery from local directories or npm packages.
      2
      MIT