# r3-yamauchi/kintone-mcp-server architecture

> Architecture diagram of the GitHub repository r3-yamauchi/kintone-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/r3-yamauchi/kintone-mcp-server
- Repository: https://github.com/r3-yamauchi/kintone-mcp-server

## Overview

##### Project Type and High-Level Purpose
- This is a backend server application written in Node.js. It demonstrates a sample implementation of an MCP server for kintone connectivity.
- It supports API operations to access and manipulate data on kintone while interfacing with external clients such as the Claude Desktop app.

##### File Structure to Determine Main Components
- Entry Point and Configuration:
– “server.js” is the primary entry point of the application.
– The project includes an environmental sample file (.env.sample) and npm configuration (package.json).
- Server Core and Request Handling:
– The “src/server” directory contains MCPServer.js which likely initializes the server and request handling.
– Handlers (e.g., ToolRequestHandler.js) within “src/server/handlers” process incoming tool requests.
- Tools and Definitions:
– The “src/server/tools” directory bundles various tool modules (e.g., AppTools.js, FileTools.js) that encapsulate business logic for specific kintone operations.
– The “src/server/tools/definitions” directory contains tool definition files mapping commands to functionality.
– There’s even a “documentation” folder under tools that outlines how different field types and layout aspects should be handled.
- Repositories and Models:
– “src/models” holds data model definitions (like KintoneCredentials.js and KintoneRecord.js).
– “src/repositories” (and its subdirectories like “base” and “validators”) implements a repository pattern to abstract interactions with kintone service endpoints—ensuring separation between business logic and direct API calls.
- Utilities:
– “src/utils/LayoutUtils.js” and potentially other utility files assist in common processing tasks.
- Documentation and Standards:
– The “clinerules-bank” and “docs” directories provide coding standards, architectural plans, and other specification documents, which are valuable for understanding design decisions.

- Client: Represent the Claude Desktop app as an external entity initiating requests to the MCP server.
- Entry Point: Server.js represents the starting point where Node.js starts the MCP server.
- MCP Server Core: Illustrate the MCPServer module under “src/server” as the orchestrator that initializes request routing.
- Tools Layer: Break down the “tools” modules (AppTools, FileTools, etc.) as components that each encapsulate domain-specific logic to implement kintone commands.
- Repository Layer: Include the repositories (with a note on the BaseKintoneRepository and various specialized repositories) that abstract the logic for making API calls to kintone.
- Models and Validators: Represent the models used by repositories and the validators (in “src/repositories/validators”) that enforce data integrity.
- Utility Components: Represent utility modules that support operations (like layout utilities) in a secondary/support role.

##### Architectural Patterns and Design Principles
- Layered Architecture: The system is cleanly separated into layers – presentation (request handlers), domain (tools and business logic), data access (repositories), and models.
- Repository Pattern: Prominent use of repositories (with a base repository and specialized validators) promotes maintainability and abstraction from the underlying kintone API.
- Modular Design: The “tools” subcomponents (each with its own definitions and documentation) indicate that the system is built for extensibility and clarity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    client["Client (Claude Desktop)"]:::client

    subgraph "MCP Server"
        server_js["server.js"]:::server
        env_sample[".env.sample"]:::server
        package_json["package.json"]:::server
        mcp_server["MCPServer.js"]:::server
        request_handler["ToolRequestHandler.js"]:::server
    end

    subgraph "Tools Components"
        app_tools["App Tools"]:::tools
        file_tools["File Tools"]:::tools
        field_tools["Field Tools"]:::tools
        layout_tools["Layout Tools"]:::tools
        record_tools["Record Tools"]:::tools
        space_tools["Space Tools"]:::tools
        system_tools["System Tools"]:::tools
        user_tools["User Tools"]:::tools
        documentation_tools["Documentation Tools"]:::tools
        tool_definitions["Tool Definitions"]:::tools
        tool_documentation["Tool Documentation"]:::tools
    end

    subgraph "Repository Layer"
        subgraph "Specialized Repositories"
            kintone_app_repo["KintoneAppRepository"]:::repository
            kintone_file_repo["KintoneFileRepository"]:::repository
            kintone_form_repo["KintoneFormRepository"]:::repository
            kintone_preview_repo["KintonePreviewRepository"]:::repository
            kintone_record_repo["KintoneRecordRepository"]:::repository
            kintone_repo["KintoneRepository"]:::repository
            kintone_space_repo["KintoneSpaceRepository"]:::repository
            kintone_user_repo["KintoneUserRepository"]:::repository
        end
        base_repo["Base Repository"]:::repository
        subgraph "Validators"
            field_validator["FieldValidator"]:::repository
            layout_validator["LayoutValidator"]:::repository
            option_validator["OptionValidator"]:::repository
        end
        repositoryAggregate["Repository Aggregate"]:::repository
    end

    subgraph "Models"
        kintone_credentials["KintoneCredentials"]:::models
        kintone_record["KintoneRecord"]:::models
    end

    utilities_node["Layout Utils"]:::utilities

    coding_standards["Coding Standards"]:::docs
    project_docs["Project Docs"]:::docs

    external_kintone["kintone API"]:::external

    %% Connections
    client -->|"sendsRequest"| server_js
    server_js -->|"initializes"| mcp_server
    mcp_server -->|"delegates"| request_handler

    request_handler -->|"handles"| app_tools
    request_handler --> file_tools
    request_handler --> field_tools
    request_handler --> layout_tools
    request_handler --> record_tools
    request_handler --> space_tools
    request_handler --> system_tools
    request_handler --> user_tools
    request_handler --> documentation_tools

    %% Link supporting tool folders
    tool_definitions ---|"supports"| app_tools
    tool_documentation ---|"supports"| app_tools

    %% Tools to Repositories
    app_tools -->|"calls"| kintone_app_repo
    file_tools -->|"calls"| kintone_file_repo
    record_tools -->|"calls"| kintone_record_repo
    space_tools -->|"calls"| kintone_space_repo
    user_tools -->|"calls"| kintone_user_repo
    field_tools -->|"calls"| kintone_repo
    layout_tools -->|"calls"| kintone_repo
    system_tools -->|"calls"| kintone_repo
    documentation_tools -->|"calls"| kintone_repo

    %% Tools using Utilities
    layout_tools ---|"uses"| utilities_node

    %% Aggregate Repository Connections
    kintone_app_repo --> repositoryAggregate
    kintone_file_repo --> repositoryAggregate
    kintone_form_repo --> repositoryAggregate
    kintone_preview_repo --> repositoryAggregate
    kintone_record_repo --> repositoryAggregate
    kintone_repo --> repositoryAggregate
    kintone_space_repo --> repositoryAggregate
    kintone_user_repo --> repositoryAggregate
    base_repo --> repositoryAggregate
    field_validator --> repositoryAggregate
    layout_validator --> repositoryAggregate
    option_validator --> repositoryAggregate

    repositoryAggregate -->|"sendsDataTo"| external_kintone

    %% Models used by Repository Layer
    repositoryAggregate ---|"uses"| kintone_credentials
    repositoryAggregate --- kintone_record

    %% Documentation guidelines
    coding_standards ---|"guides"| server_js
    project_docs ---|"guides"| server_js
    coding_standards --- documentation_tools
    project_docs --- documentation_tools

    %% Styles
    classDef client fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef server fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef tools fill:#FFECB3,stroke:#FF9800,stroke-width:2px;
    classDef repository fill:#D1C4E9,stroke:#673AB7,stroke-width:2px;
    classDef external fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef models fill:#DCEDC8,stroke:#558B2F,stroke-width:2px;
    classDef utilities fill:#F0F4C3,stroke:#9E9D24,stroke-width:2px;
    classDef docs fill:#D7CCC8,stroke:#5D4037,stroke-width:2px;

    %% Click Events
    click server_js "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/server.js"
    click env_sample "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/.env.sample"
    click package_json "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/package.json"
    click mcp_server "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/server/MCPServer.js"
    click request_handler "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/server/handlers/ToolRequestHandler.js"
    click app_tools "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/server/tools/AppTools.js"
    click file_tools "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/server/tools/FileTools.js"
    click field_tools "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/server/tools/FieldTools.js"
    click layout_tools "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/server/tools/LayoutTools.js"
    click record_tools "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/server/tools/RecordTools.js"
    click space_tools "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/server/tools/SpaceTools.js"
    click system_tools "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/server/tools/SystemTools.js"
    click user_tools "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/server/tools/UserTools.js"
    click documentation_tools "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/server/tools/DocumentationTools.js"
    click tool_definitions "https://github.com/r3-yamauchi/kintone-mcp-server/tree/main/src/server/tools/definitions"
    click tool_documentation "https://github.com/r3-yamauchi/kintone-mcp-server/tree/main/src/server/tools/documentation"
    click kintone_credentials "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/models/KintoneCredentials.js"
    click kintone_record "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/models/KintoneRecord.js"
    click kintone_app_repo "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/repositories/KintoneAppRepository.js"
    click kintone_file_repo "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/repositories/KintoneFileRepository.js"
    click kintone_form_repo "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/repositories/KintoneFormRepository.js"
    click kintone_preview_repo "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/repositories/KintonePreviewRepository.js"
    click kintone_record_repo "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/repositories/KintoneRecordRepository.js"
    click kintone_repo "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/repositories/KintoneRepository.js"
    click kintone_space_repo "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/repositories/KintoneSpaceRepository.js"
    click kintone_user_repo "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/repositories/KintoneUserRepository.js"
    click base_repo "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/repositories/base/BaseKintoneRepository.js"
    click field_validator "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/repositories/validators/FieldValidator.js"
    click layout_validator "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/repositories/validators/LayoutValidator.js"
    click option_validator "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/repositories/validators/OptionValidator.js"
    click utilities_node "https://github.com/r3-yamauchi/kintone-mcp-server/blob/main/src/utils/LayoutUtils.js"
    click coding_standards "https://github.com/r3-yamauchi/kintone-mcp-server/tree/main/clinerules-bank"
    click project_docs "https://github.com/r3-yamauchi/kintone-mcp-server/tree/main/docs"
```
