agentleFS
marianfoomarianfoo/mcp-sap-docs/AGENTS.md

mcp-sap-docs

AGENTS.md243 starsChanged 6 months agoApache-2.0View on GitHub

Operational guide for agents and contributors adding or updating documentation sources in this repository. sap-docs-mcp is an MCP server that: Core build/index flow: Adding a source is not one change in one file. A source typically needs coordinated updates in multiple places: If any of these are missed, the source may clone but never be indexed, or index without usable URL generation, or only work in one variant. Minimal source entry fields: Examples already in repo: Candidate repository: Observed docs…

We split this AGENTS.md into the rules it gives an agent

13 rules. About 0 are common, 4 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If any of these are missed, the source may clone but never be indexed, or index without usable URL generation, or only work in one variant.

    line 36
  2. Very specific:

    add source libraryId to sourceAllowlist

    line 83
  3. Very specific:

    add submodule folder path to submodulePaths

    line 84
  4. Distinctive:

    only if source should be available in ABAP variant

    line 86
  5. Very specific:

    If source indexing scans only a subfolder (for example docs), add sparse mapping so setup pulls only required paths.

    line 92
  6. Distinctive:

    If whole repo is needed, no sparse mapping is required.

    line 93
  7. Very specific:

    Add .gitmodules entry for sources/<new-folder>

    line 140
  8. Very specific:

    Add new SOURCES entry in scripts/build-index.ts

    line 141
  9. Very specific:

    Add metadata source in src/metadata.json

    line 142
  10. Distinctive:

    Add library mapping/context boosts only if useful

    line 143
  11. Very specific:

    Add setup.sh sparse path mapping if docs are in a subfolder

    line 148
  12. Very specific:

    run search with source filter and verify URLs/fetch behavior

    line 156
  13. Very specific:

    If URL generation looks wrong, verify baseUrl + pathPattern + anchorStyle first.

    line 181

≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md

Operational guide for agents and contributors adding or updating documentation sources in this repository.

What This Repository Does

sap-docs-mcp is an MCP server that:

  • pulls documentation from git submodules under sources/
  • builds a local search corpus in dist/data/index.json
  • builds SQLite FTS and embeddings (dist/data/docs.sqlite)
  • serves search/fetch tools for different variants (sap-docs, abap)

Core build/index flow:

  1. setup.sh initializes/updates submodules (variant-aware)
  2. scripts/build-index.ts scans configured source directories and creates index.json
  3. scripts/build-fts.ts builds BM25 index from index.json
  4. scripts/build-embeddings.ts builds semantic vectors

Source Onboarding Model (Important)

Adding a source is not one change in one file. A source typically needs coordinated updates in multiple places:

  1. .gitmodules (submodule URL/path/branch)
  2. scripts/build-index.ts (SOURCES entry with indexing path + file patterns)
  3. metadata config:
    • src/metadata.json for sap-docs profile
    • config/variants/abap.metadata.json if needed for abap profile
  4. variant config:
    • config/variants/sap-docs.json
    • config/variants/abap.json (if source should exist in ABAP variant)
  5. setup.sh sparse checkout mapping in get_sparse_paths() when only subfolders are needed
  6. optional test/docs updates (README, tests, validation docs)

If any of these are missed, the source may clone but never be indexed, or index without usable URL generation, or only work in one variant.

Where Source Configuration Lives

1) Submodule registration

  • File: .gitmodules
  • Purpose: declare repository origin and local path under sources/
  • Pattern:
    • path = sources/<source-folder>
    • url = https://github.com/<org>/<repo>.git
    • branch = main|master|...

2) Indexing input

  • File: scripts/build-index.ts
  • Purpose: tells indexer exactly where docs live and which files to scan
  • Structure: SOURCES: SourceConfig[]
  • Required fields:
    • repoName
    • absDir (often join("sources", "<folder>", "docs") or repo root)
    • id (library ID used everywhere, e.g. "/wdi5")
    • name, description
    • filePattern (**/*.md, **/*.mdx, etc.)
    • type (markdown, jsdoc, sample)

3) Search metadata and URL generation

  • File: src/metadata.json (sap-docs)
  • Purpose:
    • boosts, tags, synonyms/acronym context
    • source metadata for ranking and source identity
    • source URL construction (baseUrl, pathPattern, anchorStyle)

Minimal source entry fields:

  • id
  • libraryId (must match build-index.ts id)
  • sourcePath (relative to sources/)
  • baseUrl
  • pathPattern
  • anchorStyle
  • description, tags, boost

4) Variant inclusion

  • File: config/variants/sap-docs.json
    • add source libraryId to sourceAllowlist
    • add submodule folder path to submodulePaths
  • File: config/variants/abap.json
    • only if source should be available in ABAP variant

5) Setup cloning behavior

  • File: setup.sh
  • Function: get_sparse_paths()
  • If source indexing scans only a subfolder (for example docs), add sparse mapping so setup pulls only required paths.
  • If whole repo is needed, no sparse mapping is required.

Existing Patterns To Reuse

Examples already in repo:

  • Docs in docs/ folder:
    • /btp-cloud-platform -> sources/btp-cloud-platform/docs
    • /sap-artificial-intelligence -> sources/sap-artificial-intelligence/docs
  • Docs from repo root:
    • /cap -> sources/cap-docs
  • Mixed patterns (mdx, code docs, samples) exist in cloud-sdk* and openui5.

Terraform Provider BTP Candidate

Candidate repository:

Observed docs layout:

  • docs/index.md
  • docs/data-sources/
  • docs/functions/
  • docs/list-resources/
  • docs/resources/

This matches the common "docs under docs/" onboarding pattern.

Proposed source identity (suggested)

  • submodule path: sources/terraform-provider-btp
  • library ID: /terraform-provider-btp
  • sourcePath: terraform-provider-btp/docs
  • file pattern: **/*.md
  • type: markdown

Proposed metadata URL mapping (suggested)

  • baseUrl: https://github.com/SAP/terraform-provider-btp/blob/main
  • pathPattern: /docs/{file}
  • anchorStyle: github

This is consistent with existing GitHub-hosted docs sources already configured.

Step-by-Step Checklist For Adding A New Source

  1. Add .gitmodules entry for sources/<new-folder>
  2. Add new SOURCES entry in scripts/build-index.ts
  3. Add metadata source in src/metadata.json
  4. Add library mapping/context boosts only if useful
  5. Add to config/variants/sap-docs.json:
    • sourceAllowlist
    • submodulePaths
  6. Optionally add to config/variants/abap.json and ABAP metadata
  7. Add setup.sh sparse path mapping if docs are in a subfolder
  8. Run validation:
    • npm run build:index
    • npm run build:fts
    • npm run build:embeddings
    • or npm run build
  9. Smoke test search:
    • start server
    • run search with source filter and verify URLs/fetch behavior

Validation Commands

Typical local verification:

MCP_VARIANT=sap-docs npm run setup
MCP_VARIANT=sap-docs npm run build
MCP_VARIANT=sap-docs npm run start:streamable

Targeted checks:

MCP_VARIANT=sap-docs npm run build:index
MCP_VARIANT=sap-docs npm run build:fts
MCP_VARIANT=sap-docs npm run build:embeddings

Notes For Future Agents

  • sourceAllowlist and SOURCES must align; mismatches silently exclude content.
  • libraryId must match across build-index.ts, metadata, and variant allowlists.
  • submodulePaths controls what setup.sh clones; missing path means source absent locally.
  • If URL generation looks wrong, verify baseUrl + pathPattern + anchorStyle first.
  • docs/DISCOVERY_CENTER/* exists as local docs material but is not part of current indexing pipeline unless explicitly wired.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.