Skip to main content
Glama

contentrain_content_list

Retrieve and filter content entries from Contentrain's structured content management system for AI-driven content governance and localization workflows.

Instructions

List content entries (read-only). Returns data from .contentrain/ — do NOT manually create or modify content files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelYesModel ID
localeNoLocale code (defaults to config default)
filterNoFilter criteria (collection only)
resolveNoResolve relation fields to actual data
limitNoMax entries to return
offsetNoSkip N entries

Implementation Reference

  • The listContent function, which is the actual business logic for listing content entries.
    export async function listContent(
      projectRoot: string,
      model: ModelDefinition,
      opts: ListOpts,
      config: ContentrainConfig,
    ): Promise<unknown> {
      const cDir = resolveContentDir(projectRoot, model)
      const locale = opts.locale ?? config.locales.default
    
      switch (model.kind) {
        case 'singleton': {
          const data = await readJson<Record<string, unknown>>(resolveJsonFilePath(cDir, model, locale))
          return { kind: 'singleton', data: data ?? {}, locale }
        }
    
        case 'collection': {
          const data = await readJson<Record<string, Record<string, unknown>>>(resolveJsonFilePath(cDir, model, locale)) ?? {}
          let entries: Array<Record<string, unknown>> = Object.entries(data).map(([id, fields]) => {
            const entry: Record<string, unknown> = { id }
            Object.assign(entry, fields)
            return entry
          })
    
          // Filter
          if (opts.filter) {
            entries = entries.filter(entry => {
              for (const [key, value] of Object.entries(opts.filter!)) {
                if (entry[key] !== value) return false
              }
              return true
            })
          }
    
          const total = entries.length
    
          // Pagination
          const offset = opts.offset ?? 0
          const limit = opts.limit ?? entries.length
          entries = entries.slice(offset, offset + limit)
    
          // Resolve relations
          if (opts.resolve && model.fields) {
            entries = await resolveRelations(projectRoot, model, entries, locale)
          }
    
          return { kind: 'collection', data: entries, total, locale, offset, limit }
        }
    
        case 'document': {
          const entries: DocumentEntry[] = []
          const strategy = resolveLocaleStrategy(model)
    
          if (!model.i18n) {
            // No i18n: flat {slug}.md files, no locale in path
  • The registration of the 'contentrain_content_list' MCP tool, which calls listContent.
    server.tool(
      'contentrain_content_list',
      'List content entries (read-only). Returns data from .contentrain/ — do NOT manually create or modify content files.',
      {
        model: z.string().describe('Model ID'),
        locale: z.string().optional().describe('Locale code (defaults to config default)'),
        filter: z.record(z.string(), z.unknown()).optional().describe('Filter criteria (collection only)'),
        resolve: z.boolean().optional().describe('Resolve relation fields to actual data'),
        limit: z.number().optional().describe('Max entries to return'),
        offset: z.number().optional().describe('Skip N entries'),
      },
      async (input) => {
        const config = await readConfig(projectRoot)
        if (!config) {
          return {
            content: [{ type: 'text' as const, text: JSON.stringify({ error: 'Project not initialized.' }) }],
            isError: true,
          }
        }
    
        const model = await readModel(projectRoot, input.model)
        if (!model) {
          return {
            content: [{ type: 'text' as const, text: JSON.stringify({ error: `Model "${input.model}" not found` }) }],
            isError: true,
          }
        }
    
        try {
          const result = await listContent(projectRoot, model, {
            locale: input.locale,
            filter: input.filter as Record<string, unknown>,
            resolve: input.resolve,
            limit: input.limit,
            offset: input.offset,
          }, config)
    
          return {
            content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }],
          }
        } catch (error) {
          return {
            content: [{ type: 'text' as const, text: JSON.stringify({
              error: `List failed: ${error instanceof Error ? error.message : String(error)}`,
            }) }],
            isError: true,
          }
        }
      },
    )
Behavior3/5

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

No annotations provided, so description carries full burden. It discloses read-only nature and data source location (.contentrain/). However, lacks details on pagination behavior, error modes when model doesn't exist, or the structure of resolved relations.

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

Conciseness5/5

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

Two sentences with zero waste. First establishes purpose and safety profile; second provides data source context and operational warning. Efficiently front-loaded.

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

Completeness3/5

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

Given 6 parameters with nested objects and no output schema, description provides minimum viable context (purpose, read-only status, data source). Missing return value description and detailed filter semantics that would compensate for lack of output schema.

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

Parameters3/5

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

Schema coverage is 100%, establishing baseline 3. Description does not add parameter-specific semantics (e.g., filter syntax examples, resolve behavior details) beyond what the schema already documents.

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 specific verb 'List' with resource 'content entries' and includes 'read-only' parenthetical. The warning about .contentrain/ directory and manual file modification effectively distinguishes this from write-oriented siblings like contentrain_content_save.

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

Usage Guidelines3/5

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

Provides negative guidance ('do NOT manually create or modify content files') implying this is the correct read path. However, lacks explicit when-to-use guidance versus other read operations like contentrain_describe or contentrain_scan.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Contentrain/ai'

If you have feedback or need assistance with the MCP directory API, please join our Discord server