Adaptive Graph of Thoughts 标志

Adaptive Graph of Thoughts

社区
SaptaDey

LLM Reasoning Framework for Scientific Research

发布者SaptaDey
代码仓库Adaptive-Graph-of-Thoughts-MCP-server
语言Python
复刻数
9
星标数
31
可用工具
0
传输类型stdio, streamable-http
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    Adaptive Graph of Thoughts 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 31 个星标和 9 个复刻。

MseeP.ai Security Assessment Badge

🧠 Adaptive Graph of Thoughts

Version Python License Docker FastAPI NetworkX Last Updated smithery badge Codacy Security Scan CodeQL Advanced Dependabot Updates Verified on MseeP

🚀 Next-Generation AI Reasoning Framework for Scientific Research

Leveraging graph structures to transform how AI systems approach scientific reasoning


🔍 Overview

Adaptive Graph of Thoughts (AGoT) is a high-performance MCP server that implements the Advanced Scientific Reasoning Graph-of-Thoughts (ASR-GoT) framework. It uses a Neo4j graph database as a dynamic knowledge store and exposes reasoning capabilities through the Model Context Protocol (MCP), enabling seamless integration with AI assistants like Claude Desktop.

Key Highlights

FeatureDescription
🧠 Graph-Based ReasoningMulti-stage pipeline with 8 specialized reasoning stages
📊 Dynamic Confidence ScoringMulti-dimensional evaluation with uncertainty quantification
🔬 Evidence IntegrationReal-time connection to PubMed, Google Scholar & Exa Search
⚡ High PerformanceAsync FastAPI with Neo4j graph operations
🔌 MCP ProtocolNative Claude Desktop & VS Code integration
🐳 Cloud-ReadyFull Docker + Kubernetes (Helm) support

🏗️ System Architecture


🔄 ASR-GoT Reasoning Pipeline

The 8-stage reasoning pipeline transforms a raw question into a comprehensive, evidence-backed answer stored in the knowledge graph:


🕸️ Knowledge Graph Connectome

The Neo4j knowledge graph captures the reasoning structure as a rich connectome — nodes represent concepts, hypotheses, and evidence, while edges represent semantic and logical relationships:


🔁 Request Flow


📚 Documentation

Full documentation including API reference, configuration guide, and contribution guidelines:

➡️ Adaptive Graph of Thoughts Documentation Site

📂 Project Structure

Adaptive-Graph-of-Thoughts-MCP-server/
├── 📁 .github/             # CI/CD workflows (CodeQL, Dependabot)
├── 📁 agt_setup/           # Interactive setup wizard CLI
├── 📁 config/              # settings.yaml configuration
├── 📁 docs_src/            # MkDocs documentation source
├── 📁 helm/                # Kubernetes Helm chart
├── 📁 src/
│   └── 📁 adaptive_graph_of_thoughts/
│       ├── 📁 api/         # FastAPI routes & schemas
│       ├── 📁 application/ # GoTProcessor orchestrator
│       ├── 📁 domain/      # 8-stage pipeline & models
│       ├── 📁 infrastructure/ # Neo4j utilities
│       └── 📁 services/    # LLM & external API clients
├── 📁 tests/               # Comprehensive test suite
├── Dockerfile
├── docker-compose.yml
├── pyproject.toml
└── README.md

🚀 Quick Start

bash
git clone https://github.com/SaptaDey/Adaptive-Graph-of-Thoughts-MCP-server.git
cd Adaptive-Graph-of-Thoughts-MCP-server
poetry install
poetry run python -m agt_setup   # Interactive credential setup wizard
poetry run uvicorn adaptive_graph_of_thoughts.main:app --reload

Visit http://localhost:8000/docs for the interactive API documentation.

🚀 Getting Started

Deployment Prerequisites

Before running Adaptive Graph of Thoughts (either locally or via Docker if not using the provided docker-compose.prod.yml which includes Neo4j), ensure you have:

  • A running Neo4j Instance: Adaptive Graph of Thoughts requires a connection to a Neo4j graph database.

    • APOC Library: Crucially, the Neo4j instance must have the APOC (Awesome Procedures On Cypher) library installed. Several Cypher queries within the application's reasoning stages utilize APOC procedures (e.g., apoc.create.addLabels, apoc.merge.node). Without APOC, the application will not function correctly. You can find installation instructions on the official APOC website.
    • Configuration: Ensure that your config/settings.yaml (or corresponding environment variables) correctly points to your Neo4j instance URI, username, and password.
    • Indexing: For optimal performance, ensure appropriate Neo4j indexes are created. You can run python scripts/run_cypher_migrations.py to apply the provided Cypher migrations automatically. See Neo4j Indexing Strategy for details.

    Note: The provided docker-compose.yml (for development) and docker-compose.prod.yml (for production) already include a Neo4j service with the APOC library pre-configured, satisfying this requirement when using Docker Compose.

Prerequisites

  • Python 3.11+ (as specified in pyproject.toml, e.g., the Docker image uses Python 3.11.x or 3.12.x, 3.13.x)
  • Poetry: For dependency management
  • Docker and Docker Compose: For containerized deployment

Installation and Setup (Local Development)

  1. Clone the repository:

    bash
    git clone https://github.com/SaptaDey/Adaptive-Graph-of-Thoughts-MCP-server.git
    cd Adaptive-Graph-of-Thoughts-MCP-server
  2. Install dependencies using Poetry:

    bash
    poetry install

    This creates a virtual environment and installs all necessary packages specified in pyproject.toml.

  3. Activate the virtual environment:

    bash
    poetry shell
  4. Configure the application:

    bash
    # Copy example configuration
    cp config/settings.example.yaml config/settings.yaml
    
    # Edit configuration as needed
    vim config/settings.yaml
  5. Set up environment variables (optional):

    bash
    # Create .env file for sensitive configuration
    echo "LOG_LEVEL=DEBUG" > .env
    echo "API_HOST=0.0.0.0" >> .env
    echo "API_PORT=8000" >> .env

Secret Management

In production environments, set the SECRETS_PROVIDER environment variable to aws, gcp, or vault to fetch sensitive values from a supported secrets manager. Optionally provide <VAR>_SECRET_NAME variables (for example OPENAI_API_KEY_SECRET_NAME) to control the name of each secret. When a secrets provider is configured, values for OPENAI_API_KEY, ANTHROPIC_API_KEY, and NEO4J_PASSWORD are loaded automatically at startup.

  1. Run the development server:

    bash
    python src/adaptive_graph_of_thoughts/main.py

    Alternatively, for more control:

    bash
    uvicorn adaptive_graph_of_thoughts.main:app --reload --host 0.0.0.0 --port 8000

    The API will be available at http://localhost:8000.

✨ Setup Wizard

An interactive wizard is available to streamline initial configuration.

bash
poetry run python -m agt_setup

Then visit http://localhost:8000/setup to complete the web-based steps.

Setup wizard demo GIF will appear here in the full documentation.

Docker Deployment

  1. Quick Start with Docker Compose:

    bash
    # Build and run all services
    docker-compose up --build
    
    # For detached mode (background)
    docker-compose up --build -d
    
    # View logs
    docker-compose logs -f adaptive-graph-of-thoughts
  2. Individual Docker Container:

    bash
    # Build the image
    docker build -t adaptive-graph-of-thoughts:latest .
    
    # Run the container
    docker run -p 8000:8000 -v $(pwd)/config:/app/config adaptive-graph-of-thoughts:latest
  3. Production Deployment:

    bash
    # Use production compose file
    docker-compose -f docker-compose.prod.yml up --build -d

Kubernetes Deployment (Helm)

A minimal Helm chart is provided under helm/agot-server for running Adaptive Graph of Thoughts on a Kubernetes cluster.

bash
helm install agot helm/agot-server

Customize values in helm/agot-server/values.yaml to set the image repository, resource limits, and other options.

Notes on Specific Deployment Platforms

  • Smithery.ai: Deploy using the included smithery.yaml.
    • Connect your GitHub repository on Smithery and click Deploy.
    • The container listens on the PORT environment variable (default 8000).
    • Health Checks rely on the /health endpoint.
    • The Dockerfile and docker-compose.prod.yml illustrate the container setup.
  1. Access the Services:
    • API Documentation: http://localhost:8000/docs
    • Health Check: http://localhost:8000/health
    • MCP Endpoint: http://localhost:8000/mcp

🔌 MCP Client Integration

Supported MCP Clients

Adaptive Graph of Thoughts supports integration with various MCP clients:

  • Claude Desktop - Full STDIO and HTTP support
  • VS Code - Via MCP extensions
  • Custom MCP Clients - Generic configuration available

Quick Client Setup

Claude Desktop / VS Code settings

json
{
  "mcpServers": {
    "adaptive-graph-of-thoughts": {
      "command": "python",
      "args": ["-m", "adaptive_graph_of_thoughts.main"],
      "cwd": "/path/to/Adaptive-Graph-of-Thoughts-MCP-server",
      "env": {
        "NEO4J_URI": "bolt://localhost:7687",
        "NEO4J_USER": "neo4j",
        "NEO4J_PASSWORD": "your_password",
        "MCP_TRANSPORT_TYPE": "stdio"
      }
    }
  }
}

Available MCP Tools

ToolDescription
scientific_reasoning_queryAdvanced scientific reasoning with graph analysis
analyze_research_hypothesisHypothesis evaluation with confidence scoring
explore_scientific_relationshipsConcept relationship mapping
validate_scientific_claimsEvidence-based claim validation

🔌 API Endpoints

The primary API endpoints exposed by Adaptive Graph of Thoughts are:

  • MCP Protocol Endpoint: POST /mcp

    • This endpoint is used for communication with MCP clients like Claude Desktop.
    • Example Request for the asr_got.query method:
      json
      {
        "jsonrpc": "2.0",
        "method": "asr_got.query",
        "params": {
          "query": "Analyze the relationship between microbiome diversity and cancer progression.",
          "parameters": {
            "include_reasoning_trace": true,
            "include_graph_state": false
          }
        },
        "id": "123"
      }
    • Other supported MCP methods include initialize and shutdown.
  • Health Check Endpoint: GET /health

    • Provides a simple health status of the application.
    • Example Response:
      json
      {
        "status": "healthy",
        "version": "0.1.0" 
      }

The advanced API endpoints previously listed (e.g., /api/v1/graph/query) are not implemented in the current version and are reserved for potential future development.

Session Handling (session_id)

Currently, the session_id parameter available in API requests (e.g., for asr_got.query) and present in responses serves primarily to identify and track a single, complete query-response cycle. It is also used for correlating progress notifications (like got/queryProgress) with the originating query.

While the system generates and utilizes session_ids, Adaptive Graph of Thoughts does not currently support true multi-turn conversational continuity where the detailed graph state or reasoning context from a previous query is automatically loaded and reused for a follow-up query using the same session_id. Each query is processed independently at this time.

Future Enhancement: Persistent Sessions

A potential future enhancement for Adaptive Graph of Thoughts is the implementation of persistent sessions. This would enable more interactive and evolving reasoning processes by allowing users to:

  1. Persist State: Store the generated graph state and relevant reasoning context from a query, associated with its session_id, likely within the Neo4j database.
  2. Reload State: When a new query is submitted with an existing session_id, the system could reload this saved state as the starting point for further processing.
  3. Refine and Extend: Allow the new query to interact with the loaded graph—for example, by refining previous hypotheses, adding new evidence to existing structures, or exploring alternative reasoning paths based on the established context.

Implementing persistent sessions would involve developing robust strategies for:

  • Efficiently storing and retrieving session-specific graph data in Neo4j.
  • Managing the lifecycle (e.g., creation, update, expiration) of session data.
  • Designing sophisticated logic for how new queries merge with, modify, or extend pre-existing session contexts and graphs.

This is a significant feature that could greatly enhance the interactive capabilities of Adaptive Graph of Thoughts. Contributions from the community in designing and implementing persistent session functionality are welcome.

Future Enhancement: Asynchronous and Parallel Stage Execution

Currently, the 8 stages of the Adaptive Graph of Thoughts reasoning pipeline are executed sequentially. For complex queries or to further optimize performance, exploring asynchronous or parallel execution for certain parts of the pipeline is a potential future enhancement.

Potential Areas for Parallelism:

  • Hypothesis Generation: The HypothesisStage generates hypotheses for each dimension identified by the DecompositionStage. The process of generating hypotheses for different, independent dimensions could potentially be parallelized. For instance, if three dimensions are decomposed, three parallel tasks could work on generating hypotheses for each respective dimension.
  • Evidence Integration (Partial): Within the EvidenceStage, if multiple hypotheses are selected for evaluation, the "plan execution" phase (simulated evidence gathering) for these different hypotheses might be performed concurrently.

Challenges and Considerations:

Implementing parallel stage execution would introduce complexities that need careful management:

  • Data Consistency: Concurrent operations, especially writes to the Neo4j database (e.g., creating multiple hypothesis nodes or evidence nodes simultaneously), must be handled carefully to ensure data integrity and avoid race conditions. Unique ID generation schemes would need to be robust for parallel execution.
  • Transaction Management: Neo4j transactions for concurrent writes would need to be managed appropriately.
  • Dependency Management: Ensuring that stages (or parts of stages) that truly depend on the output of others are correctly sequenced would be critical.
  • Resource Utilization: Parallel execution could increase resource demands (CPU, memory, database connections).
  • Complexity: The overall control flow of the GoTProcessor would become more complex.

While the current sequential execution ensures a clear and manageable data flow, targeted parallelism in areas like hypothesis generation for independent dimensions could offer performance benefits for future versions of Adaptive Graph of Thoughts. This remains an open area for research and development.

🧪 Testing & Quality Assurance

Development Commands

Continuous integration pipelines on GitHub Actions run tests, CodeQL analysis, and Microsoft Defender for DevOps security scans.

bash
# Run full test suite with coverage using Poetry
poetry run pytest --cov=src --cov-report=html --cov-report=term

# Or using Makefile for the default test run
make test

# Run specific test categories (using poetry)
poetry run pytest tests/unit/stages/          # Stage-specific tests
poetry run pytest tests/integration/         # Integration tests
poetry run pytest -k "test_confidence"       # Tests matching pattern

# Type checking and linting (can also be run via Makefile targets: make lint, make check-types)
poetry run mypy src/ --strict                # Strict type checking
poetry run ruff check . --fix                # Auto-fix linting issues
poetry run ruff format .                     # Format code

# Pre-commit hooks (recommended)
poetry run pre-commit install                # Install hooks
poetry run pre-commit run --all-files       # Run all hooks (runs Ruff and MyPy)

# See Makefile for other useful targets like 'make all-checks'.

🖥 Dashboard Tour

Dashboard demo GIF coming soon.

💻 IDE Integration

Use the vscode-agot extension to query the server from VS Code. Run the extension and execute AGoT: Ask Graph… from the Command Palette.

❓ Troubleshooting

If the server fails to start or setup reports errors, ensure your Neo4j instance is running and the credentials in .env are correct. Consult the console output for details.

🗺️ Roadmap and Future Directions

We have an exciting vision for the future of Adaptive Graph of Thoughts! Our roadmap includes plans for enhanced graph visualization, integration with more data sources like Arxiv, and further refinements to the core reasoning engine.

For more details on our planned features and long-term goals, please see our Roadmap (also available on the documentation site).

🤝 Contributing

We welcome contributions! Please see our Contributing Guidelines (also available on the documentation site) for details on how to get started, our branching strategy, code style, and more.

📄 License

This project is licensed under the Apache License 2.0. License.

🔒 Security

Please see our Security Policy for reporting vulnerabilities and details on supported versions.

🙏 Acknowledgments

  • NetworkX community for graph analysis capabilities
  • FastAPI team for the excellent web framework
  • Pydantic for robust data validation
  • The scientific research community for inspiration and feedback

安装

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "saptadey-adaptive-graph-of-thoughts-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "Adaptive-Graph-of-Thoughts-MCP-server"
      ]
    }
  }
}

将 Adaptive Graph of Thoughts MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 Adaptive Graph of Thoughts 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 您可以在自己的设备上本地运行 MCP,也可以通过 URL 连接远程 MCP 服务器。

方式 1:使用本地连接器

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请勿关闭终端窗口或停止其中的连接器进程。
3

将 Adaptive Graph of Thoughts 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 Adaptive Graph of Thoughts MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "saptadey-adaptive-graph-of-thoughts-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "Adaptive-Graph-of-Thoughts-MCP-server"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 Adaptive Graph of Thoughts MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 Adaptive Graph of Thoughts MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 Adaptive Graph of Thoughts 帮我完成这项任务吗?
Adaptive Graph of Thoughts
当然,我看过了。
以下是我使用 Adaptive Graph of Thoughts 得到的结果。

方式 2:添加 MCP 服务器 URL

如果 Adaptive Graph of Thoughts 已托管在远程服务器上,或您的团队希望让多个用户共用一个连接器,请选择此方式。

1

打开 MCP 连接器

在 TypingMind 中,前往“插件”,打开“MCP 连接器”,然后选择“添加 URL”。

  1. 在您的浏览器中打开 TypingMind。
  2. 进入“插件”。
  3. 打开“MCP 连接器”。
  4. 点击“添加 URL”。
TypingMind 的“添加自定义 MCP 服务器 URL”表单
2

粘贴服务器 URL

在“服务器 URL”字段中输入 您的服务器 URL。根据服务器要求,添加连接名称、描述、图标、自定义 HTTP 请求头或 OAuth 客户端设置。

  1. 将 您的服务器 URL 粘贴到“服务器 URL”字段中。
  2. 为 Adaptive Graph of Thoughts 输入连接名称。
  3. 您可以添加描述和图标,以便更容易识别此连接。
  4. 如果服务器需要身份验证,请添加自定义 HTTP 请求头或 OAuth 客户端信息。
3

创建连接

点击“创建连接”,然后返回插件列表,确认新的 MCP 连接处于可用状态。

  1. 点击“创建连接”。
  2. 返回 MCP 连接器列表。
  3. 确认列表中的 Adaptive Graph of Thoughts 连接显示为可用状态。
  4. 如果连接未立即出现,请刷新插件列表。
4

切换模型,无需重新连接

使用您偏好的模型开始聊天,在“插件”中启用 Adaptive Graph of Thoughts 工具,并根据需要随时切换到其他模型。该 MCP 连接在 TypingMind 工作区中仍然可用。

  1. 在 TypingMind 中开始新聊天。
  2. 选择您想使用的 AI 模型。
  3. 在“插件”中启用 Adaptive Graph of Thoughts 工具。
  4. 需要时,请让模型使用该工具。
  5. 切换到其他 AI 模型,继续使用同一个 MCP 连接。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 Adaptive Graph of Thoughts 帮我完成这项任务吗?
Adaptive Graph of Thoughts
当然,我看过了。
以下是我使用 Adaptive Graph of Thoughts 得到的结果。

常见问题

Adaptive Graph of Thoughts MCP 服务器有什么用途?

Adaptive Graph of Thoughts 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 Adaptive Graph of Thoughts MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您无需为每个模型单独配置 MCP 服务器,就能在 Claude、ChatGPT、Gemini 或您在 TypingMind 中配置的其他 AI 模型中使用 Adaptive Graph of Thoughts。

为什么在 TypingMind 中使用 Adaptive Graph of Thoughts MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是最出色的大语言模型聊天前端之一。连接 Adaptive Graph of Thoughts 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 Adaptive Graph of Thoughts MCP 连接到 TypingMind?

在 TypingMind 中,您可以使用本地 MCP 连接器或添加远程 MCP 服务器的 URL 来连接 Adaptive Graph of Thoughts。当服务器需要访问您设备上的文件、应用或私有资源时,请使用本地连接器;如果 MCP 服务器部署在远端,请使用服务器 URL。

Adaptive Graph of Thoughts MCP 在 TypingMind 中提供哪些工具?

Adaptive Graph of Thoughts 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 Adaptive Graph of Thoughts MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行选择模型提供商,并自行管理 API 密钥、提示词和 MCP 配置。如果 Adaptive Graph of Thoughts 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇