Semantic search for Hex package documentation. Requires local Elixir and Mix installation.
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:
[!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.
The TypeScript MCP server implements the Model Context Protocol (MCP) and is designed to be used by MCP-compatible clients such as Cursor, Claude Desktop App, Continue, and others. The server provides tools for semantic search of Hex documentation. For a complete list of MCP-compatible clients, see the MCP Clients documentation.
Add this to your client's MCP json config:
{
"mcpServers": {
"hexdocs-mcp": {
"command": "npx",
"args": [
"-y",
"hexdocs-mcp@0.5.0"
]
}
}
}
This command will automatically download the elixir binaries to both fetch_docs and search documentation. While the server handles downloading the binaries, you still need Elixir and Mix installed on your system for the HexDocs fetching functionality to work properly.
Alternatively, you can use Smithery to automatically add the MCP server to your client config.
For example, for Cursor, you can use the following command:
npx -y @smithery/cli@latest install @bradleygolden/hexdocs-mcp --client cursor
Alternatively, you can add the hexdocs_mcp package to your project if you don't want to use the MCP server.
{:hexdocs_mcp, "~> 0.5.0", only: :dev, runtime: false}
And if you use floki or any other dependencies that are marked as only available in
another environment, update them to be available in the :dev
environment as well.
For example floki is commonly used in :test
:
{:floki, ">= 0.30.0", only: :test}
But you can update it to be available in the :dev environment:
{:floki, ">= 0.30.0", only: [:dev, :test]}
ollama pull mxbai-embed-large
to download the recommended embedding model⚠️ IMPORTANT: Version 0.6.0 introduces a breaking change with the default embedding model.
What changed:
nomic-embed-text
(384 dimensions) to mxbai-embed-large
(1024 dimensions)To upgrade:
Pull the new model:
ollama pull mxbai-embed-large
Your existing embeddings will be automatically cleared when you first run any command
Regenerate embeddings for your packages:
mix hex.docs.mcp fetch_docs phoenix
Why this change: mxbai-embed-large
provides significantly better semantic search quality and consistent dimensions across all platforms (Windows/macOS/Linux).
The following environment variables can be used to configure the tool:
Variable | Description | Default |
---|---|---|
HEXDOCS_MCP_PATH | Path where data will be stored | ~/.hexdocs_mcp |
HEXDOCS_MCP_MIX_PROJECT_PATHS | Comma-separated list of paths to mix.exs files | (none) |
# Set custom storage location
export HEXDOCS_MCP_PATH=/path/to/custom/directory
# Configure common project paths to avoid specifying --project flag each time
export HEXDOCS_MCP_MIX_PROJECT_PATHS="/path/to/project1/mix.exs,/path/to/project2/mix.exs"
You can also configure environment variables in the MCP configuration for the server:
{
"mcpServers": {
"hexdocs-mcp": {
"command": "...",
"args": [
"..."
],
"env": {
"HEXDOCS_MCP_PATH": "/path/to/custom/directory",
"HEXDOCS_MCP_MIX_PROJECT_PATHS": "/path/to/project1/mix.exs,/path/to/project2/mix.exs"
}
}
}
}
The MCP server can be used by any MCP-compatible AI tooling. The server will automatically fetch documentation when needed and store it in the configured data directory.
Note that large packages make take time to download and process.
The SQLite database for vector storage and retrieval is created automatically when needed.
Fetch documentation, process, and generate embeddings for a package:
mix hex.docs.mcp fetch_docs phoenix
Fetch documentation for a specific version:
mix hex.docs.mcp fetch_docs phoenix 1.5.9
Fetch documentation for a package using the version from your project:
mix hex.docs.mcp fetch_docs phoenix --project path/to/mix.exs
Configure project paths to avoid specifying them every time:
export HEXDOCS_MCP_MIX_PROJECT_PATHS="/path/to/project1/mix.exs,/path/to/project2/mix.exs"
mix hex.docs.mcp fetch_docs phoenix # Will use the first path from HEXDOCS_MCP_MIX_PROJECT_PATHS
Search in the existing embeddings:
mix hex.docs.mcp semantic_search phoenix --query "channels"
Check if embeddings exist for a package:
mix hex.docs.mcp check_embeddings phoenix
mix hex.docs.mcp check_embeddings phoenix 1.7.0
This project uses mise (formerly rtx) to manage development tools and tasks. Mise provides consistent tool versions and task automation across the project.
Install mise (if you don't have it already):
# macOS with Homebrew
brew install mise
# Using the installer script
curl https://mise.run | sh
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
Setup dependencies:
mise build
Mise defines several useful development tasks:
mise build
- Build both Elixir and TypeScript componentsmise test
- Run all testsmise mcp_inspect
- Start the MCP inspector for testing the servermise start_mcp_server
- Start the MCP server (primarily for debugging)If you prefer not to use mise, you'll need:
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
This project includes custom instructions for AI assistants to help optimize your workflow when working with Hex documentation.
You can find sample custom instructions in the repository:
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
When preparing a new release, please follow these guidelines to ensure consistency:
SemVer Compliance: Follow Semantic Versioning strictly:
Version Synchronization:
mix.exs
) and npm package version (in package.json
) MUST be identicalUpdate CHANGELOG.md:
Entry Format:
Before Release:
mix test
to ensure all tests passmix format
to ensure code is properly formattedRelease Commits:
After Release:
These guidelines apply to both human contributors and AI assistants working on this project.
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.
One API for Search, Crawling, and Sitemaps
An MCP agent that integrates various search tools using the SearchAPI service. Requires SearchAPI and Google API keys.
Fetch, convert, and search AWS documentation pages, with recommendations for related content.
Google News search capabilities with automatic topic categorization and multi-language support via SerpAPI integration.
Unlock geospatial intelligence through Mapbox APIs like geocoding, POI search, directions, isochrones and more.
Search campgrounds around the world on campertunity, check availability, and provide booking links.
Interact with the French government's open data platform (data.gouv.fr) to search for company information.
Interacting with Perplexity
Provides AI assistants with direct access to Mastra.ai's complete knowledge base.
Search Engine made for AIs by Exa