agentleFS
marianfoomarianfoo/mcp-sap-docs/.cursor/rules/20-tools-and-apis.mdc

mcp-sap-docs / rules

Cursor rule243 starsChanged 6 months agoApache-2.0View on GitHub

For tool schemas, request/response formats, and endpoints. Note: Tool names may appear with prefixes depending on MCP client (e.g., mcpsap-docs-remotesearch) @file src/lib/BaseServerHandler.ts @file src/server.ts @file src/http-server.ts @file src/streamable-http-server.ts @file src/lib/localDocs.ts @file src/lib/sapHelp.ts @file src/lib/communityBestMatch.ts @file src/lib/truncate.ts @file src/lib/config.ts @file src/lib/types.ts @file docs/CONTENT-SIZE-LIMITS.md @file docs/LLM-FRIENDLY-IMPROVEMENTS.md @file docs/ARCHITECTURE.md @file docs/DEV.md

We split this 20-tools-and-apis.mdc into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    sap_community_search: Search SAP Community posts with full content (max 75k chars per post with intelligent truncation)

    line 8
  2. Very specific:

    sap_help_search: Search SAP Help Portal using private APIs

    line 9

≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule 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
20-tools-and-apis.mdc
# MCP Tools & HTTP Endpoints (Rule)

For tool schemas, request/response formats, and endpoints.

## MCP Tools (5 total)
- **`search`**: Unified search across all documentation sources (alias: `sap_docs_search`)
- **`fetch`**: Retrieve specific documents by ID (alias: `sap_docs_get`)
- **`sap_community_search`**: Search SAP Community posts with full content (max 75k chars per post with intelligent truncation)
- **`sap_help_search`**: Search SAP Help Portal using private APIs
- **`sap_help_get`**: Retrieve full SAP Help page content (max 75k chars with intelligent truncation)

**Note**: Tool names may appear with prefixes depending on MCP client (e.g., `mcp_sap-docs-remote_search`)

## Content Size Limits
- **Maximum**: 75,000 characters (~18,750 tokens) for SAP Help and Community content
- **Algorithm**: Intelligent truncation preserving beginning (60%) and end (20%) with clear notice
- **Configuration**: `CONFIG.MAX_CONTENT_LENGTH` in `src/lib/config.ts`
- **Details**: See `docs/CONTENT-SIZE-LIMITS.md`

## Server Implementations
- **Stdio MCP**: `src/server.ts` - Main MCP server for Claude integration
- **HTTP Test Server**: `src/http-server.ts` - Development server (port 3001)
  - Endpoints: `/status`, `/healthz`, `/readyz`, `/mcp`
- **Streamable HTTP**: `src/streamable-http-server.ts` - Production HTTP MCP (port 3122)
  - Endpoints: `/mcp`, `/health`

## Response Formats

### **Standard Text Format**
- **Search Results**: `⭐️ **<id>** (Score: <score>)` format
- **Context Detection**: Emoji indicators (🎨 UI5, 🏗️ CAP, 🧪 wdi5)
- **Source Attribution**: Library grouping with clear source identification

### **ChatGPT/JSON Format**
- **Search**: `{ "results": [{ "id", "title", "url", "snippet", "score" }] }`
- **Fetch**: `{ "id", "title", "text", "url", "metadata" }`
- **Structured**: Clean JSON for programmatic access and ChatGPT compatibility

## Integration Points
- **Community**: LiQL API (search via MATCHES + post content retrieval)
- **SAP Help**: Private elasticsearch + metadata + page content APIs
- **Local Docs**: File system access with URL generation

## Configuration
- **Tool Descriptions**: Comprehensive help text in server implementations
- **Input Schemas**: Detailed parameter descriptions and examples
- **Error Handling**: Graceful fallbacks and informative error messages

@file src/lib/BaseServerHandler.ts
@file src/server.ts
@file src/http-server.ts
@file src/streamable-http-server.ts
@file src/lib/localDocs.ts
@file src/lib/sapHelp.ts
@file src/lib/communityBestMatch.ts
@file src/lib/truncate.ts
@file src/lib/config.ts
@file src/lib/types.ts
@file docs/CONTENT-SIZE-LIMITS.md
@file docs/LLM-FRIENDLY-IMPROVEMENTS.md
@file docs/ARCHITECTURE.md
@file docs/DEV.md

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.