Logo van Dual-Cycle Reasoner

Dual-Cycle Reasoner

Organisatie
cyqlelabs

A MCP server implementing the Dual-Cycle Metacognitive Reasoning Framework for autonomous agents. A loop prevention and experience recall mechanism.

Uitgevercyqlelabs
Repositorymcp-dual-cycle-reasoner
TaalTypeScript
Forks
3
Sterren
9
Beschikbare tools
0
Transporttypestdio
Categorieën
LicentieMIT
Links
  • Koppel tools aan AI-workflows

    Dual-Cycle Reasoner biedt MCP-functionaliteit die compatibele AI-clients en agenten kunnen gebruiken.

  • 0 beschikbare tools

    Bekijk hieronder de aanroepbare acties, inclusief namen en beschrijvingen als de server die beschikbaar stelt.

  • Configuratie om direct te kopiëren

    Gebruik de installatievoorbeelden om deze server in je favoriete MCP-client te configureren.

  • Indicatoren van opensource-interesse

    9 sterren en 3 forks in de gekoppelde repository.

CI codecov

A Model Context Protocol (MCP) server implementing the Dual-Cycle Metacognitive Reasoning Framework for autonomous agents. This tool empowers agents with greater self-awareness and reliability through intelligent loop detection and experience acquisition.

Description

The MCP Dual-Cycle Reasoner is a sophisticated tool designed to enhance the autonomy and reliability of AI agents. By implementing a dual-cycle metacognitive framework, it provides agents with the ability to monitor their own cognitive processes, detect when they are stuck in repetitive loops, and learn from past experiences to make better decisions.

The framework consists of two main components:

  • Sentinel: Monitors the agent's actions and detects anomalies, such as action repetition, state invariance, and progress stagnation.
  • Adjudicator: Manages a case base of past experiences, allowing the agent to store and retrieve solutions to previously encountered problems.

This server is built with TypeScript and leverages high-performance libraries for statistical analysis, natural language processing, and semantic similarity, enabling advanced features like entropy-based anomaly detection, NLI-based text analysis, and intelligent case management.

Key Features

  • 📊 Advanced Statistical Analysis: Entropy-based anomaly detection and time series analysis.
  • 🧠 Enhanced Case-Based Reasoning: Semantic similarity matching with NLI-based text analysis.
  • 🎯 Multi-Strategy Detection: Statistical, pattern-based, and hybrid loop detection.
  • 📈 Time Series Analysis: Trend detection and cyclical pattern recognition.
  • 🔧 Configurable Detection: Domain-specific thresholds and progress indicators.
  • 🎨 Intelligent Case Management: Quality scoring, deduplication, and usage-based optimization.
  • 🚀 High-Performance Libraries: Built with simple-statistics, natural, compromise, and HuggingFace Transformers.

Tech Stack

  • Language: TypeScript
  • Framework: Node.js
  • Server: FastMCP for SSE transport
  • NLP and Machine Learning:
    • @huggingface/transformers: For NLI-based semantic analysis
    • natural: For sentiment analysis and tokenization
    • compromise: For natural language processing
  • Statistics:
    • simple-statistics: For statistical calculations
    • ml-matrix: For matrix operations
  • Development Tools:
    • jest: For testing
    • eslint: For linting
    • prettier: For code formatting
    • zod: For schema validation

Installation

To get the project running locally, follow these steps:

  1. Clone the repository:

    bash
    git clone https://github.com/cyqlelabs/mcp-dual-cycle-reasoner.git
    cd mcp-dual-cycle-reasoner
  2. Install dependencies:

    bash
    npm install
  3. Build the project:

    bash
    npm run build

Usage

Running the Server

You can run the server in two modes:

  1. HTTP Stream (Default):

    bash
    npm start

    The server will start on port 8080.

  2. Stdio:

    bash
    npm start -- --stdio

Using with Claude Desktop

Add the following to your Claude Desktop MCP configuration:

json
{
  "mcpServers": {
    "dual-cycle-reasoner": {
      "command": "npx",
      "args": ["@cyqlelabs/mcp-dual-cycle-reasoner"]
    }
  }
}

For stdio transport, add the --stdio flag to the args array.

Available Tools

Core Monitoring Tools

start_monitoring

Initialize metacognitive monitoring of an agent's cognitive process.

Input Schema:

typescript
{
  goal: string; // Current goal being pursued
  initial_beliefs?: string[]; // Initial beliefs about the task
}

process_trace_update

Main monitoring function—processes cognitive trace updates from the agent.

Input Schema:

typescript
{
  last_action: string; // Latest action name
  current_context?: string; // Current environment context
  goal: string; // Current goal being pursued
  window_size?: number; // Monitoring window size (default: 10)
}

Return Payload:

Returns a JSON object indicating if intervention is required and details about any detected loop.

json
{
  "intervention_required": true,
  "loop_detected": {
    "detected": true,
    "type": "action_repetition",
    "confidence": 0.85,
    "details": "Loop detected via parameter_repetition: 57% anomaly score...",
    "actions_involved": ["click_submit_button"]
  }
}

stop_monitoring

Stop metacognitive monitoring and get a session summary.

Input Schema: {}

Loop Detection Tools

detect_loop

Detect if the agent is stuck in a loop using various strategies.

Input Schema:

typescript
{
  current_context?: string; // Current environment context
  goal: string; // Current goal being pursued
  detection_method?: "statistical" | "pattern" | "hybrid"; // Detection method (default: "hybrid")
}

Return Payload:

Returns a LoopDetectionResult object as a JSON string.

json
{
  "detected": true,
  "type": "action_repetition",
  "confidence": 0.85,
  "details": {
    "dominant_method": "parameter_repetition",
    "anomaly_score": 0.57,
    "actions_involved_count": 1,
    "recent_actions_count": 10,
    "metrics": {
      "semantic_repetition": 0.6,
      "parameter_repetition": 0.8
    }
  },
  "actions_involved": ["click_submit_button"]
}

configure_detection

Configure loop detection parameters and domain-specific progress indicators.

Input Schema:

typescript
{
  progress_indicators?: string[]; // default: []
  min_actions_for_detection?: number; // default: 5
  alternating_threshold?: number; // default: 0.5
  repetition_threshold?: number; // default: 0.4
  progress_threshold_adjustment?: number; // default: 0.2
  semantic_intents?: string[]; // default: []
}

Enhanced Experience Management

store_experience

Store a case for future case-based reasoning with enhanced metadata and quality scoring.

Input Schema:

typescript
{
  problem_description: string;
  solution: string;
  outcome: boolean;
  context?: string;
  difficulty_level?: "low" | "medium" | "high";
}

retrieve_similar_cases

Retrieve similar cases using advanced semantic matching and filtering.

Input Schema:

typescript
{
  problem_description: string;
  max_results?: number; // default: 5
  context_filter?: string;
  difficulty_filter?: "low" | "medium" | "high";
  outcome_filter?: boolean;
  min_similarity?: number; // default: 0.6
}

Return Payload:

Returns an array of Case objects as a JSON string.

json
[
  {
    "id": "case-123",
    "problem_description": "Form submission button not responding to clicks",
    "solution": "Ensure all required fields are filled correctly.",
    "outcome": true,
    "context": "registration_form",
    "difficulty_level": "medium",
    "similarity_metrics": {
      "combined_similarity": 0.92
    }
  }
]

System Tools

get_monitoring_status

Get the current monitoring status and statistics.

Input Schema: {}

Return Payload:

Returns a JSON string with the current monitoring status, including is_monitoring, current_goal, trace_length, and intervention_count.

json
{
  "is_monitoring": true,
  "current_goal": "Complete user registration process on website",
  "trace_length": 15,
  "intervention_count": 2,
  "recent_actions": [
    { "type": "click_submit_button", "timestamp": 1678886400000 },
    { "type": "click_submit_button", "timestamp": 1678886401000 }
  ]
}

reset_engine

Reset the dual-cycle engine state.

Input Schema: {}

Example Usage Scenario

Here's a complete example showing how to use the dual-cycle reasoner to monitor an autonomous agent and build up experience over time:

1. Initial Setup and Configuration

typescript
// Configure detection parameters for your domain
await configure_detection({
  progress_indicators: ['page_loaded', 'form_submitted', 'data_extracted'],
  min_actions_for_detection: 3,
  alternating_threshold: 0.6,
  repetition_threshold: 0.3,
  semantic_intents: [
    'navigating to page',
    'clicking element',
    'filling form field',
    'submitting form',
    'validating input',
    'handling popup',
    'extracting data',
    'waiting for response',
  ],
});

// Start monitoring the agent's goal
await start_monitoring({
  goal: 'Complete user registration process on website',
});

2. Monitoring Agent Actions

typescript
// Monitor each action the agent takes
await process_trace_update({
  last_action: 'click_signup_button',
  current_context: 'homepage',
  goal: 'Complete user registration process on website',
});

// ... agent continues actions ...

// Agent gets stuck clicking submit repeatedly
await process_trace_update({
  last_action: 'click_submit_button',
  current_context: 'registration_form',
  goal: 'Complete user registration process on website',
});
// Returns: {
//   "intervention_required": true,
//   "loop_detected": {
//     "detected": true,
//     "type": "action_repetition",
//     "confidence": 0.85,
//     "details": {
//       "dominant_method": "parameter_repetition",
//       "anomaly_score": 0.57,
//       "actions_involved_count": 1,
//       "recent_actions_count": 10,
//       "metrics": {
//         "semantic_repetition": 0.6,
//         "parameter_repetition": 0.8
//       }
//     },
//     "actions_involved": ["click_submit_button"]
//   }
// }

3. Storing and Retrieving Experiences

typescript
// Store a successful experience
await store_experience({
  problem_description: 'Email validation error blocking form submission',
  solution: 'Check email format and retry with valid email address',
  outcome: true,
  context: 'registration_form',
  difficulty_level: 'medium',
});

// When a loop is detected, retrieve similar cases for recovery
const similarCases = await retrieve_similar_cases({
  problem_description: 'Form submission button not responding to clicks',
  max_results: 3,
  context_filter: 'registration_form',
  outcome_filter: true,
});

Understanding Loop Detection

When the process_trace_update tool detects a potential loop, it returns a detailed loop_detected object. Understanding the components of this object can help you diagnose and debug agent behavior.

Here's a quick guide to the key metrics in the details object:

  • dominant_method: The primary method that triggered the loop detection (e.g., semantic_repetition, state_invariance).
  • anomaly_score: An overall score (0-1) representing the confidence that the agent's recent actions are part of a loop. It's a weighted average of multiple detection methods.
  • actions_involved_count: The number of recent actions identified as being part of the detected loop.
  • recent_actions_count: The total number of recent actions analyzed.
  • metrics: An object containing the raw scores from the different detection methods, such as:
    • semantic_repetition: The percentage of recent actions that are semantically similar to each other.
    • parameter_repetition: The percentage of similarity between the parameters of semantically similar actions.
    • exact_repetition: The percentage of recent actions that are exact, character-for-character duplicates.
    • cyclical_pattern: The score (0-1) indicating the presence of repeating sequences of actions.
    • oscillation_pattern: The score (0-1) indicating the presence of oscillating (back-and-forth) actions.
    • alternating_pattern: The score (0-1) indicating the presence of alternating action patterns.

Contributing

Contributions are welcome! Please read the contributing guidelines and ensure all tests pass before submitting a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Installatie

TypingMind
Vereisten:

Node.js 18+

{
  "mcpServers": {
    "dual-cycle-reasoner": {
      "command": "npx",
      "args": [
        "@cyqlelabs/mcp-dual-cycle-reasoner"
      ]
    }
  }
}

Gebruik Dual-Cycle Reasoner MCP met meerdere AI-modellen

TypingMind koppelt MCP-tools aan de werkruimte. Zodra Dual-Cycle Reasoner is verbonden, kun je deze dus met verschillende AI-modellen in TypingMind gebruiken, zonder de verbinding voor elk model apart in te stellen. Deze MCP-integratie draait lokaal via de TypingMind MCP-connector op je apparaat.

Installatiehandleiding voor de lokale connector

Gebruik dit als de MCP-server toegang nodig heeft tot lokale bestanden, apps of privébronnen op je computer.

1

Open de MCP-instellingen

Ga in TypingMind naar Instellingen, Geavanceerde instellingen en vervolgens Model Context Protocol. Kies daar Connector instellen.

  1. Open TypingMind in je browser.
  2. Klik op het pictogram Instellingen.
  3. Ga naar Geavanceerde instellingen.
  4. Open het gedeelte Model Context Protocol.
  5. Klik op Connector instellen en kies Dit apparaat.
Instelscherm voor de TypingMind MCP-connector met Dit apparaat geselecteerd
2

Voer de connectoropdracht uit

Kies Dit apparaat, kopieer de opdracht uit TypingMind en voer deze uit in Terminal. Laat het proces draaien zolang je MCP gebruikt.

  1. Kopieer de installatieopdracht die TypingMind toont.
  2. Open Terminal op macOS of Windows Terminal op Windows.
  3. Plak de opdracht en voer deze uit.
  4. Keur de pakketinstallatie goed als Terminal vraagt of je wilt doorgaan.
  5. Laat het proces in het Terminal-venster draaien zolang je MCP-tools gebruikt.
3

Voeg Dual-Cycle Reasoner toe als server

Klik op Servers bewerken zodra de connectorstatus Gereed is en plak de MCP-serverconfiguratie.

  1. Wacht tot de connectorstatus Gereed aangeeft.
  2. Klik op Servers bewerken.
  3. Plak de MCP-serverconfiguratie van Dual-Cycle Reasoner.
  4. Sla de serverlijst op.
  5. Vernieuw om te controleren of de connector nog steeds klaar is voor gebruik.
MCP-instellingen van TypingMind met een actieve server en de knop Servers bewerken
{
  "mcpServers": {
    "dual-cycle-reasoner": {
      "command": "npx",
      "args": [
        "-y",
        "@cyqlelabs/mcp-dual-cycle-reasoner"
      ]
    }
  }
}
4

Gebruik de verbinding met verschillende modellen

Sla de serverlijst op, open Plug-ins en schakel de MCP-tools van Dual-Cycle Reasoner in. Selecteer vervolgens een ondersteund AI-model in TypingMind en gebruik de tools in de chat of wijs ze toe aan een AI-agent.

  1. Open de pagina Plug-ins in TypingMind.
  2. Schakel de MCP-tools van Dual-Cycle Reasoner in.
  3. Start een chat en kies het AI-model dat je wilt gebruiken.
  4. Gebruik de MCP-tools in een chat of wijs ze toe aan een AI-agent.
  5. Schakel wanneer nodig over naar een ander AI-model zonder opnieuw verbinding te maken met MCP.
TypingMind-chat met ingeschakelde MCP-tools en een geselecteerd AI-model
Kun je Dual-Cycle Reasoner gebruiken om me hiermee te helpen?
Dual-Cycle Reasoner
Zeker. Ik heb het gelezen.
Dit vond ik met Dual-Cycle Reasoner.

Veelgestelde vragen

Waarvoor wordt de MCP-server Dual-Cycle Reasoner gebruikt?

Dual-Cycle Reasoner is een MCP-server waarmee compatibele AI-clients verbinding kunnen maken met externe tools en context. In TypingMind hoef je deze MCP-server maar één keer toe te voegen om de tools beschikbaar te maken in je AI-werkruimte.

Kan ik Dual-Cycle Reasoner MCP met meerdere AI-modellen in TypingMind gebruiken?

Ja. TypingMind verbindt MCP-tools op werkruimteniveau. Daardoor kun je Dual-Cycle Reasoner gebruiken met verschillende AI-modellen, zoals Claude, ChatGPT, Gemini of andere modellen die je in TypingMind hebt ingesteld, zonder de MCP-server voor elk model afzonderlijk in te stellen.

Waarom Dual-Cycle Reasoner MCP gebruiken met TypingMind?

TypingMind is een van de beste interfaces voor chats met LLM's, omdat het meerdere AI-modellen, prompts, plug-ins, AI-agenten, API-sleutels en MCP-tools samenbrengt in één werkruimte. Als Dual-Cycle Reasoner verbonden is, kun je de MCP-tools ervan gebruiken met je favoriete modellen en je chatworkflow overzichtelijk houden in TypingMind.

Hoe verbind ik Dual-Cycle Reasoner MCP met TypingMind?

Dual-Cycle Reasoner werkt via de lokale MCP-connector van TypingMind. Dit is de beste optie als de MCP-server toegang nodig heeft tot lokale bestanden, desktopapps, opdrachtregeltools of privébronnen op je computer.

Welke tools biedt Dual-Cycle Reasoner MCP in TypingMind?

Dual-Cycle Reasoner biedt MCP-functies die je kunt inschakelen via de pagina Plug-ins in TypingMind. Je kunt ze gebruiken in chats of toewijzen aan AI-agenten.

Moet ik mijn API-sleutels delen met TypingMind om Dual-Cycle Reasoner MCP te gebruiken?

Nee. TypingMind werkt in de eerste plaats lokaal en laat je de controle houden over je modelaanbieders, API-sleutels, prompts en MCP-configuratie. Als Dual-Cycle Reasoner authenticatie vereist, voeg je bij het maken van de verbinding de vereiste headers, OAuth-instellingen of lokale configuratie voor die MCP-server toe.

Gerelateerde MCP-servers

Toon alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇