Labsco
bradleygolden logo

HexDocs MCP

β˜… 68

from bradleygolden

Semantic search for Hex package documentation. Requires local Elixir and Mix installation.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup

HexDocs MCP

HexDocs MCP is a project that provides semantic search capabilities for Hex package documentation, designed specifically for AI applications. It consists of two main components:

  1. An Elixir binary that downloads, processes, and generates embeddings from Hex package documentation
  2. A TypeScript server implementing the Model Context Protocol (MCP) that calls the Elixir binary to fetch and search documentation

[!CAUTION] This documentation reflects the current development state on the main branch. For documentation on the latest stable release, please see the latest release page and the latest release branch.

Acknowledgements

  • hex2text - For the initial idea and as a reference

Development

This project uses mise (formerly rtx) to manage development tools and tasks. Mise provides consistent tool versions and task automation across the project.

Setting Up Development Environment

  1. Install mise (if you don't have it already):

    # macOS with Homebrew
    brew install mise
    
    # Using the installer script
    curl https://mise.run | sh
  2. Clone the repository and setup the development environment:

    git clone https://github.com/bradleygolden/hexdocs-mcp.git
    cd hexdocs-mcp
    mise install # Installs the right versions of Elixir and Node.js
  3. Setup dependencies:

    mise build

Development Tasks

Mise defines several useful development tasks:

  • mise build - Build both Elixir and TypeScript components
  • mise test - Run all tests
  • mise mcp_inspect - Start the MCP inspector for testing the server
  • mise start_mcp_server - Start the MCP server (primarily for debugging)

Without Mise

If you prefer not to use mise, you'll need:

  • Elixir 1.18.x
  • Node.js 22.x

Then, you can run these commands directly:

# Instead of mise run setup_elixir
mix setup

# Instead of mise run setup_ts
npm install

# Instead of mise run build
mix compile --no-optional-deps --warnings-as-errors
npm run build

# Instead of mise run test
mix test
mix format --check-formatted
mix deps --check-unused
mix deps.unlock --all
mix deps.get
mix test

# Instead of mise run mcp_inspect
MCP_INSPECTOR=true npx @modelcontextprotocol/inspector node dist/index.js

AI Assistant Integration

This project includes custom instructions for AI assistants to help optimize your workflow when working with Hex documentation.

Example Custom Instructions

You can find sample custom instructions in the repository:

Suggested Content

When working with Elixir projects that use Hex packages:

## HexDocs MCP Workflow

1. Use `search` to find relevant documentation
2. Use `fetch` to fetch documentation for a package

Release Guidelines

When preparing a new release, please follow these guidelines to ensure consistency:

Version Management

  1. SemVer Compliance: Follow Semantic Versioning strictly:

    • MAJOR: incompatible API changes
    • MINOR: backward-compatible functionality
    • PATCH: backward-compatible bug fixes
  2. Version Synchronization:

    • Hex package version (in mix.exs) and npm package version (in package.json) MUST be identical
    • Update both files when changing the version

Code Style

  1. Formatting and Comments:
    • Follow the Elixir formatter rules defined in .formatter.exs
    • Do not add comments to code unless strictly necessary for context
    • Self-documenting code with clear function names is preferred
    • Use module and function documentation (@moduledoc and @doc) instead of inline comments

Changelog Management

  1. Update CHANGELOG.md:

    • Document all changes under the appropriate heading (Added, Changed, Fixed, etc.)
    • Include the new version number and date
    • Keep an [Unreleased] section for tracking current changes
    • Follow the Keep a Changelog format
  2. Entry Format:

    • Use present tense, imperative style (e.g., "Add feature" not "Added feature")
    • Include issue/PR numbers where applicable
    • Group related changes

Release Process

  1. Before Release:

    • Run mix test to ensure all tests pass
    • Run mix format to ensure code is properly formatted
    • Verify CHANGELOG.md is updated
  2. Release Commits:

    • Create a version bump commit that updates:
      • mix.exs
      • package.json
      • CHANGELOG.md (move [Unreleased] to new version)
    • Tag the commit with the version number (v0.1.0 format)
  3. After Release:

    • Add a new [Unreleased] section to CHANGELOG.md
    • Update version links at the bottom of CHANGELOG.md

These guidelines apply to both human contributors and AI assistants working on this project.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

This project is licensed under MIT - see the LICENSE file for details.