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
- Distinctive: line 36
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.
- Very specific: line 83
add source libraryId to sourceAllowlist
- Very specific: line 84
add submodule folder path to submodulePaths
- Distinctive: line 86
only if source should be available in ABAP variant
- Very specific: line 92
If source indexing scans only a subfolder (for example docs), add sparse mapping so setup pulls only required paths.
- Distinctive: line 93
If whole repo is needed, no sparse mapping is required.
- Very specific: line 140
Add .gitmodules entry for sources/<new-folder>
- Very specific: line 141
Add new SOURCES entry in scripts/build-index.ts
- Very specific: line 142
Add metadata source in src/metadata.json
- Distinctive: line 143
Add library mapping/context boosts only if useful
- Very specific: line 148
Add setup.sh sparse path mapping if docs are in a subfolder
- Very specific: line 156
run search with source filter and verify URLs/fetch behavior
- Very specific: line 181
If URL generation looks wrong, verify baseUrl + pathPattern + anchorStyle first.
≈ “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.
Files
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:
setup.shinitializes/updates submodules (variant-aware)scripts/build-index.tsscans configured source directories and createsindex.jsonscripts/build-fts.tsbuilds BM25 index fromindex.jsonscripts/build-embeddings.tsbuilds 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:
.gitmodules(submodule URL/path/branch)scripts/build-index.ts(SOURCESentry with indexing path + file patterns)- metadata config:
src/metadata.jsonforsap-docsprofileconfig/variants/abap.metadata.jsonif needed forabapprofile
- variant config:
config/variants/sap-docs.jsonconfig/variants/abap.json(if source should exist in ABAP variant)
setup.shsparse checkout mapping inget_sparse_paths()when only subfolders are needed- 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>.gitbranch = 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:
repoNameabsDir(oftenjoin("sources", "<folder>", "docs")or repo root)id(library ID used everywhere, e.g."/wdi5")name,descriptionfilePattern(**/*.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:
idlibraryId(must matchbuild-index.tsid)sourcePath(relative tosources/)baseUrlpathPatternanchorStyledescription,tags,boost
4) Variant inclusion
- File:
config/variants/sap-docs.json- add source
libraryIdtosourceAllowlist - add submodule folder path to
submodulePaths
- add source
- 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 incloud-sdk*andopenui5.
Terraform Provider BTP Candidate
Candidate repository:
Observed docs layout:
docs/index.mddocs/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/mainpathPattern:/docs/{file}anchorStyle:github
This is consistent with existing GitHub-hosted docs sources already configured.
Step-by-Step Checklist For Adding A New Source
- Add
.gitmodulesentry forsources/<new-folder> - Add new
SOURCESentry inscripts/build-index.ts - Add metadata source in
src/metadata.json - Add library mapping/context boosts only if useful
- Add to
config/variants/sap-docs.json:sourceAllowlistsubmodulePaths
- Optionally add to
config/variants/abap.jsonand ABAP metadata - Add
setup.shsparse path mapping if docs are in a subfolder - Run validation:
npm run build:indexnpm run build:ftsnpm run build:embeddings- or
npm run build
- Smoke test search:
- start server
- run
searchwith 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:streamableTargeted checks:
MCP_VARIANT=sap-docs npm run build:index
MCP_VARIANT=sap-docs npm run build:fts
MCP_VARIANT=sap-docs npm run build:embeddingsNotes For Future Agents
sourceAllowlistandSOURCESmust align; mismatches silently exclude content.libraryIdmust match acrossbuild-index.ts, metadata, and variant allowlists.submodulePathscontrols whatsetup.shclones; missing path means source absent locally.- If URL generation looks wrong, verify
baseUrl+pathPattern+anchorStylefirst. docs/DISCOVERY_CENTER/*exists as local docs material but is not part of current indexing pipeline unless explicitly wired.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 28,693 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository10 other files it gives its agents.
- .cursor/rules/00-overview.mdcCursor rule
- .cursor/rules/10-search-stack.mdcCursor rule
- .cursor/rules/20-tools-and-apis.mdcCursor rule
- .cursor/rules/30-tests-and-output.mdcCursor rule
- .cursor/rules/40-deploy.mdcCursor rule
- .cursor/rules/50-metadata-config.mdcCursor rule
- .cursor/rules/60-adding-github-sources.mdcCursor rule
- .cursor/rules/70-tool-usage-guide.mdcCursor rule
- .cursor/rules/80-abap-integration.mdcCursor rule
- ui5-version-upgradeSkill
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.

