Skip to main content
Glama
This connector has been deprecated

Survey a topic across the library

shamela_survey_topic
Read-onlyIdempotent

Count how much the library holds on a term and where: the exact matching-page total plus its distribution by category, Hijri century, book and author (top 15 each). Statistics only, never passages — use shamela_search(match='words') instead to retrieve and read the pages. Run it before searching to size a topic and pick scope.category_ids (map by_category names to ids with shamela_find(kind='category')). mode 'literal' (default, 6–9 ms) counts the word as written; 'morphological' counts every derived form of its root (seconds) and is often far broader. coverage_capped:true means the breakdown is a top-5,000 sample whose counts are floors; total_hits stays exact. No match = total_hits 0; EMPTY_SCOPE when scope matches no book. Example: {term:'الاستصناع', scope:{category_ids:[14,15,16,17]}}; {term:'التيمم', scope:{citable_only:true}}.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "term": "<term>"
    },
    "name": "shamela_survey_topic"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeNo'literal' counts pages carrying the WORD as written (plus the ordinary spelling folds). 'morphological' expands it to every AlKhalil root reading and counts those — which is far broader than most callers expect: «الاستصناع» reports 393,498 pages across 7,405 books morphologically against 1,510 literally, an answer that says every shelf holds the topic. Use 'literal' to size a topic before planning retrieval; use 'morphological' to trace a ROOT through its derivations.literal
termYesArabic word or root to profile (e.g. «الاستصناع»، «صبر»، «رحم»). Under mode='literal' (default) only the word as written is counted; under mode='morphological' it is matched via the AlKhalil analyzer, so all derived forms (صابر، يصبر، اصطبار…) are counted, not just the literal string.
scopeNoRestrict the profile to specific books, authors, categories, or a Hijri date range. Use shamela_find(kind='category') / shamela_find(kind='name') to find IDs. Omit to profile the whole library installed on this server.
response_formatNoFormat of the human-readable text: 'markdown' (default) for display; 'json' the same data as one JSON code block; 'none' only a one-line pointer, leaving structuredContent as the whole answer. structuredContent is always returned, so a caller that parses it should pass 'none': the character budget counts both channels, and the unread copy otherwise spends most of it. Requires the 'response_format.none' capability (see shamela_get_brief).markdown

Output Schema

NameRequiredDescriptionDefault
modeNoliteral | morphological.
rootNoSame as `term`, for older callers.
termNo
by_bookNoTop 15 books by matching pages.
by_authorNoTop 15 authors.
truncatedNo
by_centuryNoHijri century, top 15.
total_hitsNoEXACT number of matching pages.
by_categoryNoCategory names (no ids), top 15. Reflects corpus size as well as topic, never authority: التفسير tops nearly every profile because tafsir is the largest body of text here.
scope_countNoBooks in scope; -1 when no scope was given.
coverage_capNo
rows_droppedNo
accuracy_noteNoMorphological counts: the analyzer is ~0.80 accurate on classical Arabic, so read them as reach, not exact tallies.
books_matchedNo
total_countedNoHits folded into the distribution.
coverage_cappedNoTrue when the distribution is a top-coverage_cap sample: bucket counts are floors and shares indicative.
normalized_tokensNo
truncation_messageNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare this as a safe, idempotent read; the description goes well beyond them with latency expectations (6–9 ms literal vs seconds morphological), the coverage_capped:true top-5,000 sampling contract where breakdown counts are floors while total_hits stays exact, and the EMPTY_SCOPE / zero-hit outcomes. This is disclosure an agent cannot get from the structured fields.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the purpose and the key routing sentence, and every clause carries information (sampling caveat, error names, examples). It is dense and parenthetical-heavy, which costs some readability, but there is little slack to cut.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a nested-scoped statistics tool with an output schema, the description covers what is needed to call it correctly: scope composition and intersection, id-resolution path, mode semantics, capping behaviour, and named error states. Nothing an agent must know before invoking it is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3, but the description adds genuinely new detail: the literal-vs-morphological latency difference and the warning that morphological is often far broader than expected. It also supplies two concrete scope-shaped examples, though the per-parameter semantics largely restate the already thorough schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a precise verb and resource — counts matching pages for a term plus its distribution by category, Hijri century, book and author — and immediately scopes it as 'Statistics only, never passages', which separates it from shamela_search without the agent needing to open either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit routing: use shamela_search(match='words') to retrieve passages, run this first to size a topic and choose scope.category_ids, and map names to ids via shamela_find(kind='category'). It also states the when-not case for mode ('literal' before planning retrieval, 'morphological' only to trace a root), covering alternatives and exclusion conditions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources