Protheus Research MCP Server
It is an MCP server that equips AI coding agents with authoritative TOTVS Protheus domain knowledge and diagnostics.
Search official Protheus documentation (TDN, Central de Atendimento, framework docs) with optional module/version filters.
Search community sources (forums, blogs, GitHub, Stack Overflow) for practical examples and workarounds.
Search release notes, LIB updates, patches, breaking changes, and deprecated functions.
Compare multiple sources on a topic to identify agreements, contradictions, and version-specific differences.
Run deep multi-source research producing a complete technical report with best practices, code examples, and version considerations.
Generate production-ready ADVPL/TL++/SQL/REST/SOAP/MVC code examples following modern Protheus standards.
Debug Protheus runtime errors, stack traces, and AppServer logs with probable causes, fixes, and prevention steps.
Provides structured access to TOTVS Protheus technical documentation, community knowledge, and release notes, enabling AI agents to search docs, cross-reference sources, generate ADVPL/TL++ examples, and debug runtime errors in the Protheus ecosystem.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Protheus Research MCP Server search official Protheus docs for error handling in ADVPL"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Protheus Research MCP Server
Private Model Context Protocol (MCP) Server for TOTVS Protheus Enterprise Architecture & Diagnostics
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 & COMMCore Subsystems
Protocol Core (
src/index.ts): Implements the official@modelcontextprotocol/sdkschemas (ListToolsRequestSchema,CallToolRequestSchema), handling tool discovery, parameter validation, and structured error responses.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.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.Code Synthesis Engine (
src/tools/generateExample.ts): Produces standard-compliant ADVPL, TL++, and Embedded SQL patterns adhering strictly to modern Protheus guidelines (Localvariable scoping, logical deletion handling, and cross-RDBMS query wrappers).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 patchTool Suite Specification
Tool Identifier | Scope | Technical Function |
| Official Docs | Queries TDN, Central de Atendimento, and official TOTVS frameworks with optional module and version scoping. |
| Diagnostics | Heuristic pattern analysis classifying runtime crashes, stack traces, and AppServer dumps with remediation steps. |
| Code Synthesis | Generates production-ready, canonical ADVPL, TL++, Embedded SQL, and FWRest boilerplate adhering to TOTVS modern guidelines. |
| Correlation | Orchestrates autonomous multi-tier research cross-referencing documentation, release notes, and community solutions. |
| Comparison | Cross-verifies competing implementation approaches or legacy vs. modern framework methods. |
| Community Hubs | Queries curated developer portals and forums for field-tested workarounds and niche customizations. |
| 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.
Legal Disclaimer
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 toolscompare_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
Scored across 7 tools
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.
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.
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.
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
Related MCP Connectors
The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.
MCP server unifying ERPs, CRMs, APIs and knowledge base for Claude, ChatGPT and Gemini.
MCP server for building and testing AI agents with multi-model experimentation and insights.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- AlicenseBqualityDmaintenanceAn MCP server that supercharges AI assistants with powerful tools for software development, enabling research, planning, code generation, and project scaffolding through natural language interaction.1158 npm102MIT
- FlicenseNot gradedqualityDmaintenanceA 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.-
- AlicenseNot gradedqualityBmaintenanceAn 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 npmMIT
- AlicenseNot gradedqualityCmaintenanceMCP tool server that gives any AI agent the ability to search, scrape, and analyze content across the internet.42MIT