Skip to main content
Glama
coladapo

Librarian MCP Server

by coladapo

Librarian MCP Server

An intelligent document management MCP server that leverages mental models and orchestration patterns to provide context-aware document storage, retrieval, and analysis.

Overview

The Librarian MCP Server is part of the cos mcp ecosystem and implements sophisticated document management capabilities using the Model Context Protocol. It features:

  • Intelligent Classification: Multi-dimensional document analysis

  • Mental Model Integration: Leverages frameworks from the MCP Orchestrator

  • Proactive Assistance: Pattern detection and organization suggestions

  • Flexible Storage: Adapter pattern for multiple storage backends

  • Semantic Search: Natural language document retrieval

Related MCP server: KnowledgeMCP

Architecture

Built using patterns from the MCP Orchestrator:

  • Classification Engine for multi-dimensional analysis

  • Intent Router for operation routing

  • Storage Adapters for backend flexibility

  • Proactive patterns for intelligent suggestions

See ARCHITECTURE.md for detailed design documentation.

Installation

npm install
npm run build

Usage

Run the Server

npm start

Configure with Claude Desktop

Add to your Claude Desktop configuration:

{
  "mcpServers": {
    "librarian": {
      "command": "node",
      "args": ["/path/to/librarian/dist/index.js"]
    }
  }
}

Available Tools

Document Management

  • store_document: Store documents with automatic classification

  • search_documents: Search using natural language or filters

  • get_document: Retrieve specific documents

  • update_document: Update document content or metadata

  • delete_document: Remove documents from library

Analysis & Organization

  • analyze_document: Apply mental models for document analysis

  • organize_library: AI-driven document organization

Examples

Store a Document

{
  "tool": "store_document",
  "arguments": {
    "content": "# Project Plan\n\nThis document outlines...",
    "metadata": {
      "title": "Q1 2024 Project Plan",
      "author": "John Doe",
      "tags": ["planning", "quarterly"]
    },
    "options": {
      "autoClassify": true,
      "detectDuplicates": true
    }
  }
}

Search Documents

{
  "tool": "search_documents",
  "arguments": {
    "query": "project plans from last quarter",
    "filters": {
      "domain": ["business"],
      "dateRange": {
        "start": "2024-01-01"
      }
    },
    "options": {
      "semantic": true,
      "limit": 5
    }
  }
}

Analyze Document

{
  "tool": "analyze_document",
  "arguments": {
    "documentId": "doc-123",
    "analysisType": "summary",
    "framework": "swot"
  }
}

Integration with MCP Orchestrator

The Librarian can be integrated with the MCP Orchestrator for advanced workflows:

  1. Use orchestrator to analyze complex queries

  2. Route document operations through mental models

  3. Chain multiple operations for sophisticated workflows

Example orchestrated workflow:

1. Gather intent about document needs
2. Search relevant documents
3. Analyze using appropriate mental models
4. Organize based on patterns
5. Generate insights

Development

Project Structure

librarian/
├── src/
│   ├── adapters/      # Storage backend adapters
│   ├── engines/       # Classification and analysis engines
│   ├── tools/         # MCP tool definitions
│   ├── types.ts       # TypeScript type definitions
│   ├── LibrarianServer.ts  # Main server implementation
│   └── index.ts       # Entry point
├── ARCHITECTURE.md    # Detailed architecture documentation
├── package.json
└── README.md

Adding New Features

  1. New Storage Backend: Implement the StorageAdapter interface

  2. New Analysis Type: Add to AnalysisType enum and implement handler

  3. New Organization Method: Add to OrganizeMethod and implement logic

Testing

# Run in development mode
npm run dev

# Test with MCP Inspector
npx @modelcontextprotocol/inspector dist/index.js

Future Enhancements

  • PostgreSQL adapter with vector embeddings

  • Integration with filesystem MCP for local files

  • Browser MCP integration for web content

  • Real-time collaboration features

  • Advanced duplicate detection

  • Custom mental model definitions

  • Batch import/export capabilities

License

MIT

Contributing

Contributions welcome! Please follow the existing patterns and ensure TypeScript compilation succeeds before submitting PRs.

Available Tools

7 tools
analyze_documentC

Analyze a document using various frameworks and mental models

ParametersJSON Schema
NameRequiredDescriptionDefault
optionsNo
frameworkNoMental model framework to apply
documentIdYesID of the document to analyze
analysisTypeYesType of analysis to perform

TDQS

C2.8/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It does not state whether the tool modifies data, requires authorization, or has side effects. The description is too vague to inform an agent about important behavioral aspects.

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

Conciseness3/5

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

The description is a single sentence, which is concise but lacks depth. It could be improved by adding more details without becoming overly long. The front-loading is adequate but the content is too generic.

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

Completeness2/5

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

Given the tool has 4 parameters including a nested object, no output schema, and no annotations, the description is insufficient to fully understand the tool's behavior and usage. It does not explain what the return value is, how frameworks affect analysis, or how to use the options parameter.

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?

The input schema has 75% coverage with descriptions for documentId, analysisType, and framework. The general description adds no additional meaning beyond the schema, so it meets the baseline for high coverage. However, the 'options' parameter lacks a description, and the description does not clarify parameter usage.

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

Purpose4/5

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

The description clearly states the verb 'analyze' and the resource 'document', and mentions using frameworks and mental models. However, it does not specify the scope or types of analysis, and it could be more specific to differentiate from sibling tools like get_document.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. There is no mention of prerequisites, exclusions, or when not to use it. The description fails to help the agent decide between analyze_document and other document tools like search_documents or get_document.

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

delete_documentC

Delete a document from the library

ParametersJSON Schema
NameRequiredDescriptionDefault
confirmYesConfirmation to delete
documentIdYesThe document ID to delete

TDQS

C2.9/5.0
Behavior2/5

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

The description indicates a destructive action ('delete') but provides no behavioral details beyond that. No annotations are present, so the description holds the burden, yet it lacks information on consequences (e.g., irreversibility, cascading effects, permission requirements). The 'confirm' parameter in the schema is not highlighted.

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?

The description is a single, efficient sentence that conveys the core action. It is front-loaded with the verb and resource, but could be slightly expanded without becoming verbose.

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

Completeness2/5

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

For a destructive operation with no annotations or output schema, the description is incomplete. It omits information about return values, error conditions, side effects, or any other context needed for safe use. The tool's simplicity (2 params) only partially mitigates this.

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?

The input schema has 100% description coverage for both parameters. The tool description does not add any additional meaning beyond what the schema already provides. Baseline score of 3 is appropriate.

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

Purpose4/5

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

The description clearly states the action ('Delete') and the resource ('a document from the library'), which is sufficiently specific for basic identification. However, it does not differentiate from sibling tools like 'update_document' or 'get_document', but since deletion is a distinct operation, the purpose is clear.

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

Usage Guidelines2/5

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

There is no information on when to use this tool versus alternatives, nor any mention of prerequisites or scenarios where deletion should be avoided. The description simply states the action without context.

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

get_documentC

Retrieve a specific document by ID

ParametersJSON Schema
NameRequiredDescriptionDefault
documentIdYesThe document ID to retrieve
includeAnalysisNoInclude previous analysis results

TDQS

C2.9/5.0
Behavior2/5

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

No annotations are provided, so the description must cover behavioral traits like read-only nature, error handling (e.g., what if ID not found), or required permissions. The description only states a simple retrieval with no such disclosure.

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?

The description is a single sentence that efficiently conveys the core functionality. Every word is necessary, and it is front-loaded with the action and resource.

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

Completeness2/5

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

For a tool with 2 parameters and no output schema, the description is too minimal. It lacks information about the return format, possible errors, or any side effects. The agent cannot fully understand what to expect.

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 description coverage is 100%, so parameters are already well-documented. The description adds no extra meaning beyond what's in the schema. Baseline 3 is appropriate as the description does not add significant value but doesn't detract.

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

Purpose4/5

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

The description clearly states the action (retrieve) and resource (document by ID). It is specific and easily understood. Although it doesn't explicitly differentiate from siblings, context from sibling names like 'delete_document' and 'analyze_document' makes the purpose clear.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives. For example, it doesn't mention that for searching, 'search_documents' should be used, or that for analyzing, 'analyze_document' is appropriate. The agent is left to infer context.

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

organize_libraryC

Organize documents using AI-driven patterns and mental models

ParametersJSON Schema
NameRequiredDescriptionDefault
scopeYesScope of documents to organize
methodYesOrganization method to apply
optionsNo
strategyYesOrganization strategy

TDQS

C2.8/5.0
Behavior2/5

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

No annotations are provided, and the description does not disclose behavioral traits such as modification permissions, destructive nature, or side effects. The dryRun option in the schema implies preview capability, but this is not highlighted in the description.

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

Conciseness3/5

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

The description is very concise (one sentence) but lacks detail and could be more tailored to the tool's complexity. It is not verbose, but it is too brief to be fully informative.

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

Completeness2/5

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

Given the tool's complexity (4 parameters, 3 enums, nested object, no output schema), the description is insufficient. It does not explain return values, organization methods, or the AI-driven process.

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 description coverage is high (75%), so the schema itself documents parameters adequately. The description adds no additional meaning beyond what the schema provides.

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

Purpose4/5

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

The description clearly states the tool organizes documents using AI-driven patterns, and it distinguishes from siblings like delete or search. However, it lacks specificity about what 'patterns and mental models' means.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives. The description does not mention prerequisites, context, or exclusions.

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

search_documentsC

Search documents using natural language or structured filters

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesNatural language search query
filtersNo
optionsNo

TDQS

C2.7/5.0
Behavior2/5

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

No annotations are provided, so the description must bear the full burden of behavioral disclosure. It fails to mention key traits such as whether the operation is read-only, whether authentication is required, what happens on empty results, or any rate limits. The brief description does not compensate for the missing annotations.

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?

The description is a single, concise sentence that starts with the action verb. It avoids unnecessary words and explains the core function efficiently. However, it could be structured to include more details without becoming verbose, such as a brief note on output or limitations.

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

Completeness2/5

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

For a tool with three parameters, nested objects, and no output schema, the description is too minimal. It does not indicate what the search returns (e.g., structured results, snippets), how results are ordered, or any pagination behavior. An agent would need to infer too much from the schema alone.

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

Parameters2/5

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

Schema description coverage is low (33%), meaning the tool description should compensate for missing schema details. However, the description only vaguely references 'natural language or structured filters', which maps to 'query' and 'filters' parameters but adds no specifics about valid values, defaults, or the 'options' parameter. The nested object structure is not explained.

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

Purpose4/5

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

The description clearly states the verb 'Search' and resource 'documents', and mentions the two search modes: natural language or structured filters. This differentiates it from sibling tools like get_document (retrieve by ID) and analyze_document (analyze). However, it could be more specific about the scope (e.g., within workspace or globally) to fully distinguish from similar tools.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus its siblings, such as get_document or analyze_document. It does not mention prerequisites, fallback strategies, or when not to use it. For example, if an agent needs a specific document by ID, get_document would be more appropriate, but this is not indicated.

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

store_documentC

Store a document with intelligent classification and organization

ParametersJSON Schema
NameRequiredDescriptionDefault
contentYesThe document content
optionsNo
metadataYes

TDQS

C2.4/5.0
Behavior2/5

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

With no annotations, the description must bear the full burden of behavioral disclosure. It mentions 'intelligent classification and organization' but does not explain what side effects occur, such as whether duplicates are checked, embeddings generated, or metadata modified. The description is too vague for an agent to understand the tool's behavior.

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

Conciseness3/5

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

The description is a single sentence, making it concise, but it lacks structure and front-loads only the overall purpose. It is appropriately short yet sacrifices necessary detail.

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

Completeness2/5

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

Given the tool has 3 parameters (including nested objects), no output schema, and moderate complexity, the description is inadequate. It does not explain return values, error conditions, or the behavior of the optional 'intelligent' features, leaving the agent underinformed.

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

Parameters2/5

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

Schema description coverage is only 33% (only 'content' has a top-level description). The description adds no additional meaning beyond the schema's parameter descriptions. It does not clarify the expected format or constraints for 'content', 'options', or 'metadata'.

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

Purpose3/5

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

The description clearly states the action (store) and the resource (document). The mention of 'intelligent classification and organization' gives a sense of capabilities but lacks specificity and does not distinguish this tool from siblings like 'analyze_document' or 'organize_library'.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. There are no when-to-use or when-not-to-use statements. The description implies a general storage scenario, but context for appropriate usage is absent.

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

update_documentC

Update document metadata or content

ParametersJSON Schema
NameRequiredDescriptionDefault
updatesYes
documentIdYesThe document ID to update
reclassifyNoRe-run classification after update

TDQS

C2.8/5.0
Behavior2/5

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

No annotations provided, so description carries full burden. It doesn't disclose whether updates are partial or full replacements, what happens to unspecified fields, or any side effects like reclassification triggering. The 'content' field says 'replaces existing', but metadata and tags behavior is ambiguous.

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

Conciseness3/5

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

Extremely concise at 5 words, but this sacrifices completeness. It front-loads the purpose but omits essential behavioral details that a longer description could include.

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

Completeness2/5

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

With no output schema and a complex nested input (updates with addTags, removeTags, content, metadata), the description fails to explain return values, error handling, or the net effect of update operations. For a mutation tool, this is insufficient.

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 description coverage is 67% (all top-level and nested parameters have descriptions). The description adds little beyond summarizing the update action. It doesn't clarify parameter relationships or provide examples.

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

Purpose4/5

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

The description clearly states the tool updates document metadata or content, distinguishing it from siblings like store, delete, get. However, it lacks specificity about which metadata fields are modifiable, though the schema fills that gap.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives (e.g., store_document for creation, get_document for retrieval). No prerequisites or context about when not to use it.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 7 tool updatesv1.0.0
    • First observedanalyze_document
    • First observeddelete_document
    • First observedget_document
    • First observedorganize_library
    • First observedsearch_documents
    • First observedstore_document
    • First observedupdate_document

TDQS

B3.3/5.0

Scored across 7 tools

Disambiguation5/5

Each tool addresses a distinct operation on documents (CRUD, search, analysis, organization) with no overlapping purposes, ensuring clear differentiation.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern (e.g., store_document, search_documents), with 'organize_library' also conforming, providing predictability.

Tool Count5/5

Seven tools is well-scoped for a document library server, covering essential CRUD operations plus analysis and organization without unnecessary bloat.

Completeness4/5

The set covers core lifecycle and value-added features, but an explicit list_all or batch operation tool is missing, relying on search with unfiltered queries as a workaround.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    An MCP server that enables AI assistants to perform semantic searches over local document collections using multi-context organization and automatic OCR. It supports various file formats including PDF, DOCX, and images, ensuring all data processing remains local and private.
    7
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    MCP server for structured document management of markdown and YAML files, with RBAC, git-based approval workflows, and semantic search, enabling agents to read, edit, and maintain documents under governance.
    MIT