Skip to main content
Glama
Protheus Research MCP Server

Protheus Research MCP Server

by limaduzz11

Protheus Research MCP Server

Private Model Context Protocol (MCP) Server for TOTVS Protheus Enterprise Architecture & Diagnostics

Node.js TypeScript Model Context Protocol Status License

English  |  Português (Brasil)

A specialized Model Context Protocol (MCP) middleware engineered to equip AI coding agents with domain-specific intelligence, structured documentation retrieval, stack trace heuristic diagnostics, and canonical ADVPL/TL++ syntax standards across the TOTVS Protheus ecosystem.


Table of Contents


Related MCP server: GenZ MCP Server

Concept & Rationale

Software engineering within the TOTVS Protheus ERP environment presents distinct domain challenges:

  • Proprietary language syntaxes (ADVPL, TL++) that standard, general-purpose LLMs frequently misinterpret or hallucinate.

  • Extensive, disparate documentation repositories across TDN (TOTVS Developer Network), technical issue bulletins, and release notes.

  • Complex AppServer runtime execution behaviors, including memory management quirks, database cursors (GetNextAlias, ChangeQuery), and runtime stack traces (Access Violations, Array Bounds, lock contention).

The Protheus Research MCP Server operates as a structured semantic bridge. Conforming strictly to the Model Context Protocol (MCP) specification, it exposes clean, deterministic tools that AI agent platforms (such as Claude, Cursor, OpenCode, and Antigravity) invoke dynamically to ground their code suggestions and architectural diagnostics in authoritative technical facts.


System Architecture

The server runs as a state-isolated daemon communicating via the standard JSON-RPC 2.0 protocol over standard input/output (stdio):

graph TD
    subgraph AI Host Environment
        Agent[AI Agent / LLM Host<br/>Claude / Cursor / OpenCode / Antigravity]
        ClientTransport[MCP Client Transport]
    end

    subgraph Protheus Research MCP Engine
        StdioTransport[StdioServerTransport<br/>JSON-RPC 2.0]
        Router[Tool Execution Router]
        Cache[In-Memory TTL Cache<br/>600s TTL / Deduplication]
        
        subgraph Toolset [Registered Capabilities]
            T1[search_protheus_docs]
            T2[search_community]
            T3[search_release_notes]
            T4[compare_sources]
            T5[deep_research]
            T6[generate_advpl_example]
            T7[debug_protheus_error]
        end

        Ranker[Source Ranker & Normalizer]
        Heuristic[Error Categorization Matrix]
    end

    subgraph External Technical Knowledge
        TDN[(TOTVS TDN / Central de Atendimento)]
        GH[(Official TOTVS Repositories)]
        COMM[(Recognized Community Portals)]
    end

    Agent <-->|JSON-RPC Tools| ClientTransport
    ClientTransport <-->|stdio stream| StdioTransport
    StdioTransport --> Router
    Router --> Cache
    Router --> Toolset
    T1 & T2 & T3 & T4 & T5 --> Ranker
    T7 --> Heuristic
    Ranker --> TDN & GH & COMM

Core Subsystems

  1. Protocol Core (src/index.ts): Implements the official @modelcontextprotocol/sdk schemas (ListToolsRequestSchema, CallToolRequestSchema), handling tool discovery, parameter validation, and structured error responses.

  2. Deterministic Source Ranker (src/services/searcher.ts): Prioritizes official TOTVS documentation domains (tdn.totvs.com, centraldeatendimento.totvs.com) as Level 1 authoritative sources, indexing recognized technical community portals as Level 2 advisory references.

  3. Error Heuristic Engine (src/tools/debugError.ts): Pattern-matching matrix analyzing raw Protheus AppServer error logs, categorizing failure classes (Array Bounds, Access Violations, Deadlocks, REST/SOAP faults, Database timeouts), and returning structured remediation workflows.

  4. Code Synthesis Engine (src/tools/generateExample.ts): Produces standard-compliant ADVPL, TL++, and Embedded SQL patterns adhering strictly to modern Protheus guidelines (Local variable scoping, logical deletion handling, and cross-RDBMS query wrappers).

  5. In-Memory Cache (src/utils/cache.ts): Fast, key-value TTL store preventing outbound duplicate requests and upstream rate-limiting during recursive multi-step reasoning runs.


Agent Tool-Call Lifecycle

sequenceDiagram
    autonumber
    actor Engineer as Software Engineer
    participant Agent as AI Agent (Claude / Cursor / Antigravity)
    participant MCP as Protheus Research MCP Server
    participant Cache as In-Memory Cache
    participant Engine as Search & Parser Pipeline
    participant Sources as TDN & Knowledge Portals

    Engineer->>Agent: "Diagnose AppServer error: array out of bounds in U_MYFUNC"
    Agent->>MCP: CallToolRequest("debug_protheus_error", { errorMessage: "...", stackTrace: "..." })
    
    MCP->>Cache: Check cached diagnostic fingerprint
    alt Cache Hit
        Cache-->>MCP: Return cached diagnosis
    else Cache Miss
        MCP->>MCP: Execute heuristic error classification
        MCP->>Engine: Dispatch targeted documentation search
        Engine->>Sources: Query TDN articles & known issues
        Sources-->>Engine: Raw documentation snippets & URLs
        Engine->>MCP: Normalized, relevance-scored references
        MCP->>Cache: Store result (10-minute TTL)
    end

    MCP-->>Agent: CallToolResult(Structured diagnosis, root causes, corrective code)
    Agent-->>Engineer: Synthesizes precise root cause and validated ADVPL patch

Tool Suite Specification

Tool Identifier

Scope

Technical Function

search_protheus_docs

Official Docs

Queries TDN, Central de Atendimento, and official TOTVS frameworks with optional module and version scoping.

debug_protheus_error

Diagnostics

Heuristic pattern analysis classifying runtime crashes, stack traces, and AppServer dumps with remediation steps.

generate_advpl_example

Code Synthesis

Generates production-ready, canonical ADVPL, TL++, Embedded SQL, and FWRest boilerplate adhering to TOTVS modern guidelines.

deep_research

Correlation

Orchestrates autonomous multi-tier research cross-referencing documentation, release notes, and community solutions.

compare_sources

Comparison

Cross-verifies competing implementation approaches or legacy vs. modern framework methods.

search_community

Community Hubs

Queries curated developer portals and forums for field-tested workarounds and niche customizations.

search_release_notes

Lifecycle

Checks issue resolutions, cumulative update packages, and framework changes across Protheus releases.

Tool Schemas & Payloads

1. search_protheus_docs

// Input Schema
{
  "query": "FWRest",
  "module": "SIGAFAT",
  "version": "12.1.2210"
}

// Sample Output Payload
{
  "results": [
    {
      "title": "FWRest - Framework ADVPL - TDN",
      "url": "https://tdn.totvs.com/display/tec/FWRest",
      "snippet": "Classe para consumo de serviços RESTful em ADVPL, suportando métodos HTTP padronizados, SSL e manipulação de cabeçalhos.",
      "sourceType": "official_tdn",
      "sourceLevel": 1,
      "relevance": 95
    }
  ],
  "totalFound": 12
}

2. debug_protheus_error

// Input Schema
{
  "errorMessage": "array out of bounds [0] of [1] on U_MYFUNC(MYFUNC.PRW)",
  "stackTrace": "U_MYFUNC (MYFUNC.PRW) 15/08/2026 14:22:01",
  "environment": "Protheus 12.1.2210, SQL Server 2019"
}

// Sample Output Payload
{
  "diagnosis": "Category: Array Bounds. 6 authoritative references located.",
  "probableCauses": [
    "Attempting to read index <= 0 or beyond array length (Len(aArray)).",
    "Empty dataset returned by query/DbSeek without length validation prior to indexing."
  ],
  "verificationSteps": [
    "Inspect AppServer console log for full execution context.",
    "Verify RPO compilation status and dictionary synchronization."
  ],
  "fixes": [
    "Enforce defensive boundary checks using If Len(aData) >= nIndex before accessing aData[nIndex].",
    "Initialize dynamic collections safely using AAdd() or aClone()."
  ]
}

3. generate_advpl_example

// Input Schema
{
  "language": "advpl",
  "description": "Query customers from SA1 with logic deletion handling and JSON serialization",
  "context": "Faturamento (SIGAFAT)"
}

// Sample Output Payload
{
  "language": "advpl",
  "bestPractices": [
    "Enforce explicit Local variable declarations for predictable memory scope.",
    "Use GetNextAlias() to avoid cursor collisions in concurrent threads.",
    "Apply ChangeQuery() for cross-database portability.",
    "Always verify logical deletion flag (D_E_L_E_T_)."
  ]
}

Security & Enterprise Isolation

  • Air-Gapped Operation: The server operates strictly as an analytical knowledge middleware. It does not establish direct connections to customer production ERP databases, DBAccess ports, or live transactional tables.

  • Zero Sensitive Data Ingestion: The engine does not store, transmit, or process client business records, ERP credentials, or proprietary business logic.

  • Controlled Outbound Communication: Web requests are strictly confined to public documentation hosts (TDN, Central de Atendimento, GitHub) over standard TLS/HTTPS.


System Scope

This repository documents the architectural blueprint, design patterns, and capability contracts of the Protheus Research MCP Server. As a private enterprise asset tailored to specialized development environments, public distribution packages, automated build artifacts, and client environment configurations are maintained outside public repositories.


TOTVS, Protheus, ADVPL, and TL++ are registered trademarks of TOTVS S.A. This project is an independent developer productivity and architectural research middleware. It is neither affiliated with, sponsored by, nor endorsed by TOTVS S.A.


License

All rights reserved. Proprietary software. Refer to LICENSE for terms.


Available Tools

7 tools
compare_sourcesA

Compare multiple information sources (official vs community) on a given topic. Identifies agreements, contradictions, and version-specific differences. Useful when documentation is conflicting or unclear.

Inputs: query (required), topics.

debug_protheus_errorA

Investigate Protheus runtime errors, stack traces, AppServer logs, and common failures. Combines official and community knowledge for diagnosis, probable causes, fixes, and prevention. Supports: Access Violations, Array Bounds, Deadlocks, REST/SOAP failures, DBAccess errors, License errors, and more.

Inputs: errorMessage (required), stackTrace, environment.

deep_researchA

Orchestrate comprehensive research across ALL sources for a Protheus topic. Aggregates results, ranks sources by reliability, removes duplicates, and produces a complete technical report with summary, explanation, official docs, community findings, best practices, common mistakes, code examples, and version considerations.

Inputs: query (required), depth, modules, versions.

generate_advpl_exampleA

Generate production-ready, modern ADVPL/TL++ code examples based on researched material. Supports ADVPL, TL++, SQL, REST, SOAP, and MVC patterns. Code follows modern standards: LOCAL variables, Framework APIs, SQL Server syntax, no obsolete patterns.

Inputs: language (required), description (required), context.

search_communityA

Search trusted Protheus community sources: Terminal de Informação, BlackTDN, MasterADVPL, Universo ADVPL, GitHub, Stack Overflow, and technical blogs. Use this to find practical examples, workarounds, and real-world experiences.

Inputs: query (required), includeForums.

search_protheus_docsA

Search official TOTVS Protheus documentation across TDN, Central de Atendimento, Framework docs, and Release Notes. Use this tool when you need authoritative, official TOTVS documentation for any Protheus-related topic. Always prefer this over community sources for factual technical information.

Inputs: query (required), module, version.

search_release_notesA

Search for TOTVS Protheus release notes, LIB updates, patches, behavior changes, breaking changes, and deprecated functions across versions.

Inputs: product (required), patch, version.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 7 tools

    Disambiguation4/5

    Each tool has a clear primary purpose, and the distinctions between search_protheus_docs, search_community, and search_release_notes are well-defined by source type. There is slight overlap between search_protheus_docs and search_release_notes since release notes are part of official docs, but the descriptions reduce ambiguity.

    Naming Consistency5/5

    All tool names follow a consistent snake_case verb_noun pattern: search, compare, generate, debug. Even 'deep_research' fits the pattern as a verb-like compound. No mixed conventions or inconsistent casing.

    Tool Count5/5

    Seven tools is well within the ideal 3-15 range for a focused research and assistance server. Each tool covers a distinct aspect of the Protheus ecosystem, and none feel redundant or unnecessary.

    Completeness5/5

    The tool surface covers the full research lifecycle: searching official and community sources, checking release notes, comparing sources, running deep aggregated research, generating code examples, and debugging errors. This leaves no obvious dead ends for common Protheus developer tasks.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      A streamlined MCP server that provides essential AI-powered tools for interactive development chat and systematic root cause analysis. It supports multiple AI providers to help developers brainstorm technical solutions and perform evidence-based debugging.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      An MCP server that provides tools for retrieving and processing documentation through vector search, enabling AI assistants to augment their responses with relevant documentation context.
      15 npm
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      MCP tool server that gives any AI agent the ability to search, scrape, and analyze content across the internet.
      42
      MIT