# Knowledge Graph Causal Discovery MCP (`ryanclinton/knowledge-graph-causal-discovery-mcp`) Actor

Construct causal graphs from multi-domain data, apply do-calculus reasoning, and estimate causal effects via semiparametric methods -- all through a single MCP interface.

- **URL**: https://apify.com/ryanclinton/knowledge-graph-causal-discovery-mcp.md
- **Developed by:** [ryan clinton](https://apify.com/ryanclinton) (community)
- **Categories:** AI, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event + usage

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Knowledge Graph Causal Discovery MCP Server

**Construct causal graphs from multi-domain data**, apply **do-calculus reasoning**, and estimate **causal effects via semiparametric methods** -- all through a single MCP interface. This server orchestrates **17 Apify actors** across academic, biomedical, regulatory, economic, and safety data sources, then applies rigorous causal inference algorithms including **FCI structure discovery**, **TMLE estimation**, **RotatE knowledge graph embeddings**, and **sheaf cohomology consistency checking**. Every tool returns structured scoring with mathematical foundations.

### What data can you access?

| Data Point | Source | Coverage |
|------------|--------|----------|
| Academic papers and citations | OpenAlex, Semantic Scholar, Crossref | Global research output |
| Preprints and open access | ArXiv, CORE | Physics, CS, biology, math |
| Biomedical literature | PubMed | 36M+ biomedical citations |
| Clinical trials | ClinicalTrials.gov | 450K+ registered trials |
| NIH research grants | NIH Reporter | Active and historical NIH funding |
| Drug adverse events | OpenFDA | FDA adverse event reports |
| Federal regulations | Federal Register | US regulatory actions |
| Congressional legislation | Congress.gov | Bills and resolutions |
| Government datasets | Data.gov | Federal open data |
| Economic indicators | FRED | Federal Reserve economic data |
| World development indicators | World Bank | 200+ country indicators |
| Product recalls | CPSC | Consumer product safety recalls |
| Consumer complaints | CFPB | Financial consumer complaints |
| Encyclopedia context | Wikipedia | Background knowledge |

### MCP Tools

| Tool | Price | Description |
|------|-------|-------------|
| `discover_causal_structure` | $0.10 | Discover causal structure via FCI with KCI tests and GES scored by BIC. Returns directed/bidirectional edges, Markov equivalence class, and BIC score. |
| `compute_interventional_effects` | $0.10 | Compute P(Y\|do(X)) via do-calculus with back-door/front-door criteria and Balke-Pearl LP bounds for unidentified effects. |
| `simulate_counterfactuals` | $0.10 | Simulate counterfactual outcomes via twin network method. Returns probability of necessity (PN) and sufficiency (PS) with monotonicity checks. |
| `extract_causal_claims_literature` | $0.10 | Extract causal claims from academic literature via NLP pattern matching and evidence level classification (RCT, observational, case study, review). |
| `embed_causal_knowledge_graph` | $0.10 | Embed causal knowledge graph via RotatE complex-valued embeddings. Returns entity embeddings, link prediction metrics (MRR, Hits@10), and clusters. |
| `estimate_causal_effect_tmle` | $0.10 | Estimate causal effects via TMLE with Super Learner ensemble. Returns ATE, influence function norms, and cross-validated risk. |
| `check_graph_consistency` | $0.10 | Check causal graph consistency via sheaf cohomology. Tests acyclicity, faithfulness, causal sufficiency, instrument validity, and Markov compatibility. |
| `attribute_source_contribution` | $0.10 | Attribute data source contributions to causal graph quality via Shapley values. Returns marginal contributions, nucleolus, and core stability. |

### Data Sources

- **OpenAlex** -- Open scholarly metadata covering 250M+ works with citation graphs and author disambiguation
- **Semantic Scholar** -- AI-powered academic search with citation context and influential citation detection
- **Crossref** -- DOI registration agency with 150M+ metadata records and reference linking
- **ArXiv** -- Open access preprint server for physics, mathematics, computer science, and quantitative biology
- **CORE** -- Aggregator of 300M+ open access research papers from repositories worldwide
- **PubMed** -- MEDLINE biomedical literature database with MeSH indexing and structured abstracts
- **ClinicalTrials.gov** -- Registry of 450K+ clinical studies with protocol details and outcome data
- **NIH Reporter** -- NIH-funded research grants with investigator, institution, and project details
- **OpenFDA Drug Events** -- FDA adverse event reporting system (FAERS) for drug safety surveillance
- **Federal Register** -- Daily journal of US government regulatory actions and proposed rules
- **Congress Bill Tracker** -- Legislative tracking for bills, resolutions, and amendments in Congress
- **Data.gov** -- Federal open data platform with 300K+ government datasets
- **FRED Economic Data** -- Federal Reserve economic time series including GDP, inflation, employment, and rates
- **World Bank Data** -- Development indicators across 200+ countries covering health, economics, and infrastructure
- **CPSC Recall Search** -- Consumer Product Safety Commission recall notices and safety alerts
- **CFPB Complaints** -- Consumer Financial Protection Bureau complaint database with company responses
- **Wikipedia** -- Encyclopedia articles providing background context and entity descriptions

### How the scoring works

Each tool applies a specific **causal inference algorithm** to the knowledge graph built from multi-source data.

**Structure discovery** uses FCI (Fast Causal Inference) tolerant of latent confounders, combined with GES (Greedy Equivalence Search) scored by BIC. Additive noise model orientation uses HSIC independence between residuals and cause.

**Interventional effects** apply Pearl's three do-calculus rules and the ID algorithm. Back-door and front-door adjustment criteria identify estimable effects. Balke-Pearl LP bounds constrain unidentified effects via linear programming.

**Counterfactual simulation** uses the twin network method with factual world (X=x, Y=y) and counterfactual world (X=x') sharing exogenous variables. Tian-Pearl monotonicity bounds are validated.

**TMLE estimation** follows the targeted maximum likelihood pipeline: Super Learner initial estimate, propensity score with positivity truncation, clever covariate, targeting step, and influence-function-based confidence intervals.

| Score Dimension | Range | Interpretation |
|----------------|-------|----------------|
| BIC Score | Lower is better | Model fit quality for causal structure |
| Branching Ratio | 0.0 - 1.0 | Stability of causal graph (< 1 = stable) |
| ATE (Average Treatment Effect) | Varies | Estimated causal effect magnitude |
| MRR (Mean Reciprocal Rank) | 0.0 - 1.0 | Knowledge graph embedding quality |
| Shapley Value | 0.0 - 1.0 | Data source contribution proportion |

### How to connect this MCP server

#### Claude Desktop

Add to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "knowledge-graph-causal-discovery": {
      "url": "https://knowledge-graph-causal-discovery-mcp.apify.actor/mcp"
    }
  }
}
````

#### Programmatic (cURL)

```bash
curl -X POST https://knowledge-graph-causal-discovery-mcp.apify.actor/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_APIFY_TOKEN" \
  -d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"discover_causal_structure","arguments":{"query":"smoking lung cancer","sources":["academic","biomedical"]}},"id":1}'
```

#### Other MCP clients

This server works with any MCP-compatible client including **Cursor**, **Windsurf**, **Cline**, and custom MCP integrations. Point your client to the endpoint `https://knowledge-graph-causal-discovery-mcp.apify.actor/mcp`.

### Use cases for causal discovery intelligence

#### Drug safety signal detection

Discover causal links between pharmaceutical compounds and adverse events by combining PubMed literature, clinical trial data, and FDA adverse event reports into a unified causal graph.

#### Policy impact assessment

Estimate the causal effect of regulatory interventions on economic outcomes by combining Federal Register rules, FRED economic indicators, and World Bank development data.

#### Systematic review automation

Extract and classify causal claims across thousands of academic papers, detecting conflicting evidence and grading claim strength from RCTs down to case studies.

#### Knowledge graph completion

Use RotatE embeddings to predict missing causal links in biomedical knowledge graphs, identifying undiscovered drug-disease or gene-pathway relationships.

#### Data source prioritization

Apply Shapley value attribution to determine which data sources contribute most to causal inference quality, guiding data acquisition and budget allocation decisions.

#### Treatment effect estimation

Use TMLE with Super Learner ensembles to estimate average treatment effects from observational data, producing doubly-robust confidence intervals.

### How much does it cost?

This MCP uses **pay-per-event** pricing. You are only charged when a tool is called.

Each tool call costs **$0.10**. The Apify Free plan includes **$5 of monthly platform credits**, enough for approximately 50 causal discovery queries per month.

| Usage Example | Estimated Cost |
|--------------|----------------|
| Single causal structure discovery | $0.10 |
| Full pipeline (structure + intervention + counterfactual) | $0.30 |
| Literature review with claim extraction | $0.10 |
| Source attribution analysis across all 5 domains | $0.10 |

### How it works

1. **Tool call received** -- Your MCP client sends a query with optional source category selection (academic, biomedical, regulatory, economic, safety).
2. **Parallel actor execution** -- Up to 17 Apify actors run simultaneously across selected source categories, fetching papers, trials, regulations, economic indicators, and safety data.
3. **Knowledge graph construction** -- Results are merged into a unified causal knowledge graph with nodes (entities, variables, concepts) and edges (causal claims, correlations, references).
4. **Algorithm application** -- The requested causal inference algorithm is applied: FCI/GES for structure, do-calculus for interventions, twin networks for counterfactuals, TMLE for estimation, RotatE for embeddings, or sheaf cohomology for consistency.
5. **Structured response** -- Results are returned as structured JSON with scores, confidence metrics, and supporting evidence.

### FAQ

**Q: How fresh is the data?**
A: All data is fetched live at query time from each source API. Results reflect the current state of OpenAlex, PubMed, FRED, and all other databases.

**Q: Can I select which data sources to use?**
A: Yes. Every tool accepts a `sources` parameter with options: `academic`, `biomedical`, `regulatory`, `economic`, and `safety`. You can use any combination.

**Q: What is the difference between the structure discovery and interventional tools?**
A: Structure discovery finds the causal graph (which variables cause which). Interventional effects compute what happens when you force a variable to a specific value. Use structure discovery first, then interventional analysis.

**Q: Is this a replacement for randomized controlled trials?**
A: No. This provides causal inference from observational data and literature synthesis. It identifies causal hypotheses and estimates effects, but observational causal inference has inherent limitations compared to experimental designs.

**Q: Is it legal to use this data?**
A: All data sources are publicly available APIs and open databases. See [Apify's guide on web scraping legality](https://blog.apify.com/is-web-scraping-legal/).

**Q: Can I combine this with other MCP servers?**
A: Yes. Use this MCP for causal analysis, then feed findings into other intelligence MCPs for domain-specific risk scoring or monitoring.

### Related MCP servers

| MCP Server | Focus |
|------------|-------|
| [ryanclinton/open-source-supply-chain-risk-mcp](https://apify.com/ryanclinton/open-source-supply-chain-risk-mcp) | OSS dependency risk and vulnerability propagation |
| [ryanclinton/market-microstructure-manipulation-mcp](https://apify.com/ryanclinton/market-microstructure-manipulation-mcp) | Market manipulation detection with Granger causality |
| [ryanclinton/litigation-intelligence-mcp](https://apify.com/ryanclinton/litigation-intelligence-mcp) | Pre-litigation risk scoring from regulatory signals |

### Integrations

This MCP server runs on the **Apify platform** and integrates with the broader Apify ecosystem:

- **Apify API** -- Call this MCP programmatically from any language via the Apify API
- **Scheduling** -- Set up recurring causal analysis runs on a schedule
- **Webhooks** -- Trigger downstream workflows when causal analysis completes
- **Integrations** -- Connect to Slack, Zapier, Make, or any webhook-compatible service for automated alerts

# Actor input Schema

## Actor input object example

```json
{}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("ryanclinton/knowledge-graph-causal-discovery-mcp").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("ryanclinton/knowledge-graph-causal-discovery-mcp").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call ryanclinton/knowledge-graph-causal-discovery-mcp --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=ryanclinton/knowledge-graph-causal-discovery-mcp",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Knowledge Graph Causal Discovery MCP",
        "description": "Construct causal graphs from multi-domain data, apply do-calculus reasoning, and estimate causal effects via semiparametric methods -- all through a single MCP interface.",
        "version": "1.0",
        "x-build-id": "YpyEK42K1BJy63DuG"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/ryanclinton~knowledge-graph-causal-discovery-mcp/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-ryanclinton-knowledge-graph-causal-discovery-mcp",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/ryanclinton~knowledge-graph-causal-discovery-mcp/runs": {
            "post": {
                "operationId": "runs-sync-ryanclinton-knowledge-graph-causal-discovery-mcp",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/ryanclinton~knowledge-graph-causal-discovery-mcp/run-sync": {
            "post": {
                "operationId": "run-sync-ryanclinton-knowledge-graph-causal-discovery-mcp",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {}
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
