npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

dynamic-context-mcp

v1.0.9

Published

MCP server for dynamic context injection based on glob patterns

Readme

Dynamic Context MCP Server

A Model Context Protocol (MCP) server that injects "Just-in-Time" context into AI conversations based on file paths and glob patterns.

License TypeScript

🚀 What is this?

When coding with AI, you often have specific guidelines, architectural patterns, or database schemas that apply only to certain parts of your codebase.

Dynamic Context MCP allows you to define these rules in Markdown files with glob pattern headers. When the AI agent (like Claude or Gemini) looks at a specific file path, this tool automatically injects the relevant context for that file.

Example Flow:

  1. You are working on src/backend/api.ts.
  2. The AI calls this tool with that path.
  3. This server finds backend-guidelines.md (which matches src/backend/**/*.ts).
  4. The server also finds general-ts-guidelines.md (which matches *.ts)
  5. It combines all matching context files and delivers the result to your AI agent before it generates code

📦 usage

Quick Start (instead of manual setup)

Run the init command to automatically detect your framework (Laravel, Next.js, Python), create starter rules in .agent/rules, and append (NOT OVERWRITE) your primary context files (like GEMINI.md, CLAUDE.md, or .cursorrules) with the necessary instructions.

npx dynamic-context-mcp init

1. Prepare your Context Directory

Create a folder (default is .agent/rules) in your project root. Add markdown files with YAML frontmatter containing globs (either a single string or a list).

Example 1: Single Glob

File: .agent/rules/styles.md

---
trigger: glob
globs: "**/*.css"
---

# CSS Rules

- Use flexbox layout.

Example 2: Multiple Globs & Brace Expansion

File: .agent/rules/frontend.md

---
trigger: glob
globs:
  - "src/helpers/**/*.ts"
  - "resources/js/**/*.{vue,ts}" # Matches both .vue and .ts files
---

# Frontend Rules

- Ensure strict type checking.
- Prefer Composition API for Vue files.

Example 3: Always Trigger

Use this for high-level rules that should apply to every file, such as general coding standards or project philosophy.

File: .agent/rules/general.md

---
trigger: always
---

# General Guidelines

- Write clean, commented code.
- Follow SOLID principles.

2. Configure your AI Client

Add this to your MCP configuration file (e.g., claude_desktop_config.json):

{
  "mcpServers": {
    "dynamic-context": {
      "command": "npx",
      "args": [
        "-y",
        "dynamic-context-mcp",
        "/optional/absolute/path/to/your/project/.agent/rules"
      ]
    }
  }
}

Note: The last argument is optional. If omitted, it looks for .agent/rules in the directory where the MCP server runs.

3. IMPORTANT: Agent Configuration

To ensure your AI agent uses this tool effectively, add the following instruction to your agent's system prompt or custom instructions (e.g., in GEMINI.md, CLAUDE.md, or your agent's settings):

<!-- DYNAMIC CONTEXT MCP GUIDELINES START -->

<CRITICAL_INSTRUCTION>

## DYNAMIC CONTEXT INSTRUCTIONS

This project uses dynamic context mcp to deliver "just in time" context for files that you are about to read, create, or edit.

**CRITICAL GUIDANCE**

- Before you read, create, or edit a file, check for dynamic context by requesting the `dynamic-context.get_context_for_file` tool with the file path as input.
- If dynamic context is available, read it carefully to understand important details about how to work with that file.

</CRITICAL_INSTRUCTION>

<!-- DYNAMIC CONTEXT MCP GUIDELINES END -->

🛠 Local Development

If you want to modify or contribute to this project:

  1. Clone the repo:

    git clone [https://github.com/yourusername/dynamic-context-mcp.git](https://github.com/yourusername/dynamic-context-mcp.git)
    cd dynamic-context-mcp
  2. Install dependencies:

    npm install
  3. Build the project:

    npm run build
  4. Test locally: You can run the compiled script directly:

    node dist/index.js ./path/to/test/context-folder

🤝 Contributing

Contributions are welcome!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

Distributed under the MIT License.