Skip to main content

Offer documentation in your local filesystem as references via mcp tools

Project description

local-references-mcp

A local reference management and preview tool, built on FastMCP, for serving and interacting with local reference files (such as documentation, best practices, or knowledge snippets) via an MCP Server.

Useful to allow a coding assistant to preview local documentation, best practices, or knowledge snippets.

The Story

Imagine you're in the Beats repo and you tell it that there's a "Winlogbeat" reference at https://github.com/elastic/beats/tree/main/docs/reference/winlogbeat. For this, you'd pass --reference "Winlogbeat:docs/reference/winlogbeat". From there, the LLM has a couple of tools available to it.

List References

When the LLM calls List References, something like this is returned:

  # Local References 
  Below is a list of available reference types. We will show each type, and a preview of its entries.Note: previews are truncated to 1000 characters.
  
  ## References for: `Winlogbeat`
  Below are the available references that you can leverage when working with Winlogbeat
  
  ### Type: `Winlogbeat`, Name: `Add cloud metadata`
  The add_cloud_metadata processor enriches each event with instance metadata from the machine’s hosting provider. At startup it will query a list of hosting providers and cache the instance metadata.

  ### Type: `Winlogbeat`, Name: `Add Cloud Foundry metadata`
  The add_cloudfoundry_metadata processor annotates each event with relevant metadata from Cloud Foundry applications. The events are annotated with Cloud Foundry metadata, only if the event contains a reference to a Cloud Foundry application (using field cloudfoundry.app.id) and the configured Cloud Foundry client is able to retrieve information for the application.
  ....

and if the LLM wants the full reference can call, get_reference("Winlogbeat", "Add Cloud Metadata")

You can have the LLM run list_references automatically on start-up and then it knows how and where to get best practices, how tos, etc from the docs in your repo.

This is especially useful when you want to expose guides / instructions to an LLM without giving it general read/write access to the filesystem.

VS Code McpServer Usage

  1. Open the command palette (Ctrl+Shift+P or Cmd+Shift+P).
  2. Type "Settings" and select "Preferences: Open User Settings (JSON)".
  3. Add the following MCP Server configuration
{
    "mcp": {
        "servers": {
            "Local References": {
                "command": "uvx",
                "args": [
                    "git+https://github.com/strawgate/py-mcp-collection.git#subdirectory=local-references-mcp",
                    "--reference",
                    "Best Practices:/docs/best_practices.md",
                    "--reference",
                    "How To:/docs/how_to.md"
                ]
            }
        }
    }
}

Roo Code / Cline McpServer Usage

Simply add the following to your McpServer configuration. Edit the AlwaysAllow list to include the tools you want to use without confirmation.

    "Local References": {
      "command": "uvx",
      "args": [
        "git+https://github.com/strawgate/py-mcp-collection.git#subdirectory=local-references-mcp"
      ]
    }

Development

uv sync --group dev

Usage

Command-Line Interface

Run the MCP server with your references:

python -m local_references_mcp.main --reference "Type1:/path/to/file1.md" --reference "Type2:/path/to/file2.md"
  • Each --reference argument should be in the format name:path.
  • You can specify multiple references.

Example

python -m local_references_mcp.main --reference "Best Practices:/docs/best_practices.md" --reference "How To:/docs/how_to.md"

How It Works

  • Reference: Represents a single reference file, identified by a name and a path.
  • ReferenceEntry: Represents an entry within a reference (currently, each reference is a single file).
  • ReferenceManager: Manages a collection of references, provides preview and retrieval tools, and integrates with FastMCP.

Extending

To add new reference types or customize entry parsing, extend the Reference and ReferenceEntry classes in references.py.

Development & Testing

  • Tests should be placed alongside the source code or in a dedicated tests/ directory.
  • Use pytest for running tests.
pytest

License

See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

local_references_mcp-0.5.2.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

local_references_mcp-0.5.2-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file local_references_mcp-0.5.2.tar.gz.

File metadata

  • Download URL: local_references_mcp-0.5.2.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.20

File hashes

Hashes for local_references_mcp-0.5.2.tar.gz
Algorithm Hash digest
SHA256 c88f5574162afbf7770d1281030b8759dfcbc2ac37333ba2658aa95d1d7af10f
MD5 2943de9acbef5142547ed3a5dd8e7dcd
BLAKE2b-256 8bbcda600615cbb9cc81965e082aa2027edd3978ce2fd3377d66caec89c74718

See more details on using hashes here.

File details

Details for the file local_references_mcp-0.5.2-py3-none-any.whl.

File metadata

File hashes

Hashes for local_references_mcp-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a213b02c4a960bf8b9cdae5cb3666e8cf41c68054d9f24729d69a62551b70717
MD5 bec43c6c47dacb734f109bf8f1242312
BLAKE2b-256 8bb3db46279935705df3c973b8fe4641528d0d0845b80ae73a4d9a7b648f5f67

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page