contradiction-mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +536 -0
  3. package/bin/cli.js +182 -0
  4. package/dist/analysis/claimMatcher.d.ts +48 -0
  5. package/dist/analysis/claimMatcher.js +131 -0
  6. package/dist/analysis/claimMatcher.js.map +1 -0
  7. package/dist/analysis/claimRelationship.d.ts +15 -0
  8. package/dist/analysis/claimRelationship.js +12 -0
  9. package/dist/analysis/claimRelationship.js.map +1 -0
  10. package/dist/analysis/confidenceScorer.d.ts +40 -0
  11. package/dist/analysis/confidenceScorer.js +59 -0
  12. package/dist/analysis/confidenceScorer.js.map +1 -0
  13. package/dist/analysis/contextAnalyzer.d.ts +13 -0
  14. package/dist/analysis/contextAnalyzer.js +187 -0
  15. package/dist/analysis/contextAnalyzer.js.map +1 -0
  16. package/dist/analysis/contradictionClassifier.d.ts +16 -0
  17. package/dist/analysis/contradictionClassifier.js +141 -0
  18. package/dist/analysis/contradictionClassifier.js.map +1 -0
  19. package/dist/analysis/contradictionEngine.d.ts +29 -0
  20. package/dist/analysis/contradictionEngine.js +284 -0
  21. package/dist/analysis/contradictionEngine.js.map +1 -0
  22. package/dist/analysis/explanationBuilder.d.ts +36 -0
  23. package/dist/analysis/explanationBuilder.js +77 -0
  24. package/dist/analysis/explanationBuilder.js.map +1 -0
  25. package/dist/analysis/valueComparator.d.ts +38 -0
  26. package/dist/analysis/valueComparator.js +418 -0
  27. package/dist/analysis/valueComparator.js.map +1 -0
  28. package/dist/config/env.d.ts +46 -0
  29. package/dist/config/env.js +34 -0
  30. package/dist/config/env.js.map +1 -0
  31. package/dist/connectors/base/connectorUtils.d.ts +26 -0
  32. package/dist/connectors/base/connectorUtils.js +63 -0
  33. package/dist/connectors/base/connectorUtils.js.map +1 -0
  34. package/dist/connectors/base/security.d.ts +11 -0
  35. package/dist/connectors/base/security.js +9 -0
  36. package/dist/connectors/base/security.js.map +1 -0
  37. package/dist/connectors/connectorRegistry.d.ts +43 -0
  38. package/dist/connectors/connectorRegistry.js +91 -0
  39. package/dist/connectors/connectorRegistry.js.map +1 -0
  40. package/dist/connectors/document/documentConnector.d.ts +45 -0
  41. package/dist/connectors/document/documentConnector.js +410 -0
  42. package/dist/connectors/document/documentConnector.js.map +1 -0
  43. package/dist/connectors/github/githubClient.d.ts +52 -0
  44. package/dist/connectors/github/githubClient.js +207 -0
  45. package/dist/connectors/github/githubClient.js.map +1 -0
  46. package/dist/connectors/github/githubConnector.d.ts +26 -0
  47. package/dist/connectors/github/githubConnector.js +169 -0
  48. package/dist/connectors/github/githubConnector.js.map +1 -0
  49. package/dist/connectors/github/githubExtractor.d.ts +26 -0
  50. package/dist/connectors/github/githubExtractor.js +469 -0
  51. package/dist/connectors/github/githubExtractor.js.map +1 -0
  52. package/dist/connectors/github/githubNormalizer.d.ts +11 -0
  53. package/dist/connectors/github/githubNormalizer.js +24 -0
  54. package/dist/connectors/github/githubNormalizer.js.map +1 -0
  55. package/dist/connectors/github/githubTypes.d.ts +55 -0
  56. package/dist/connectors/github/githubTypes.js +2 -0
  57. package/dist/connectors/github/githubTypes.js.map +1 -0
  58. package/dist/connectors/syncService.d.ts +60 -0
  59. package/dist/connectors/syncService.js +176 -0
  60. package/dist/connectors/syncService.js.map +1 -0
  61. package/dist/connectors/types/connector.d.ts +34 -0
  62. package/dist/connectors/types/connector.js +2 -0
  63. package/dist/connectors/types/connector.js.map +1 -0
  64. package/dist/connectors/types/fetchResult.d.ts +39 -0
  65. package/dist/connectors/types/fetchResult.js +2 -0
  66. package/dist/connectors/types/fetchResult.js.map +1 -0
  67. package/dist/connectors/website/ssrfGuard.d.ts +11 -0
  68. package/dist/connectors/website/ssrfGuard.js +122 -0
  69. package/dist/connectors/website/ssrfGuard.js.map +1 -0
  70. package/dist/connectors/website/websiteConnector.d.ts +30 -0
  71. package/dist/connectors/website/websiteConnector.js +231 -0
  72. package/dist/connectors/website/websiteConnector.js.map +1 -0
  73. package/dist/discovery/candidateGenerator.d.ts +12 -0
  74. package/dist/discovery/candidateGenerator.js +110 -0
  75. package/dist/discovery/candidateGenerator.js.map +1 -0
  76. package/dist/discovery/contradictionScanner.d.ts +30 -0
  77. package/dist/discovery/contradictionScanner.js +47 -0
  78. package/dist/discovery/contradictionScanner.js.map +1 -0
  79. package/dist/discovery/discoveryService.d.ts +37 -0
  80. package/dist/discovery/discoveryService.js +131 -0
  81. package/dist/discovery/discoveryService.js.map +1 -0
  82. package/dist/discovery/rankingService.d.ts +34 -0
  83. package/dist/discovery/rankingService.js +52 -0
  84. package/dist/discovery/rankingService.js.map +1 -0
  85. package/dist/discovery/similarityIndex.d.ts +20 -0
  86. package/dist/discovery/similarityIndex.js +89 -0
  87. package/dist/discovery/similarityIndex.js.map +1 -0
  88. package/dist/domain/entities/claim.d.ts +99 -0
  89. package/dist/domain/entities/claim.js +92 -0
  90. package/dist/domain/entities/claim.js.map +1 -0
  91. package/dist/domain/entities/contradiction.d.ts +110 -0
  92. package/dist/domain/entities/contradiction.js +74 -0
  93. package/dist/domain/entities/contradiction.js.map +1 -0
  94. package/dist/domain/entities/source.d.ts +43 -0
  95. package/dist/domain/entities/source.js +35 -0
  96. package/dist/domain/entities/source.js.map +1 -0
  97. package/dist/domain/types/common.d.ts +46 -0
  98. package/dist/domain/types/common.js +74 -0
  99. package/dist/domain/types/common.js.map +1 -0
  100. package/dist/httpServer.d.ts +25 -0
  101. package/dist/httpServer.js +164 -0
  102. package/dist/httpServer.js.map +1 -0
  103. package/dist/index.d.ts +1 -0
  104. package/dist/index.js +94 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/intelligence/authorityScorer.d.ts +20 -0
  107. package/dist/intelligence/authorityScorer.js +103 -0
  108. package/dist/intelligence/authorityScorer.js.map +1 -0
  109. package/dist/intelligence/entityResolver.d.ts +33 -0
  110. package/dist/intelligence/entityResolver.js +152 -0
  111. package/dist/intelligence/entityResolver.js.map +1 -0
  112. package/dist/intelligence/evidenceEvaluator.d.ts +15 -0
  113. package/dist/intelligence/evidenceEvaluator.js +63 -0
  114. package/dist/intelligence/evidenceEvaluator.js.map +1 -0
  115. package/dist/intelligence/freshnessScorer.d.ts +25 -0
  116. package/dist/intelligence/freshnessScorer.js +90 -0
  117. package/dist/intelligence/freshnessScorer.js.map +1 -0
  118. package/dist/intelligence/provenanceAnalyzer.d.ts +19 -0
  119. package/dist/intelligence/provenanceAnalyzer.js +33 -0
  120. package/dist/intelligence/provenanceAnalyzer.js.map +1 -0
  121. package/dist/intelligence/resolutionAdvisor.d.ts +40 -0
  122. package/dist/intelligence/resolutionAdvisor.js +118 -0
  123. package/dist/intelligence/resolutionAdvisor.js.map +1 -0
  124. package/dist/intelligence/semanticMatcher.d.ts +21 -0
  125. package/dist/intelligence/semanticMatcher.js +71 -0
  126. package/dist/intelligence/semanticMatcher.js.map +1 -0
  127. package/dist/scripts/comprehensiveVerification.d.ts +5 -0
  128. package/dist/scripts/comprehensiveVerification.js +961 -0
  129. package/dist/scripts/comprehensiveVerification.js.map +1 -0
  130. package/dist/scripts/finalLiveDemo.d.ts +5 -0
  131. package/dist/scripts/finalLiveDemo.js +226 -0
  132. package/dist/scripts/finalLiveDemo.js.map +1 -0
  133. package/dist/scripts/liveMcpSmoke.d.ts +1 -0
  134. package/dist/scripts/liveMcpSmoke.js +89 -0
  135. package/dist/scripts/liveMcpSmoke.js.map +1 -0
  136. package/dist/scripts/seedDemoData.d.ts +6 -0
  137. package/dist/scripts/seedDemoData.js +179 -0
  138. package/dist/scripts/seedDemoData.js.map +1 -0
  139. package/dist/server.d.ts +28 -0
  140. package/dist/server.js +1264 -0
  141. package/dist/server.js.map +1 -0
  142. package/dist/services/analysisService.d.ts +40 -0
  143. package/dist/services/analysisService.js +65 -0
  144. package/dist/services/analysisService.js.map +1 -0
  145. package/dist/services/healthService.d.ts +42 -0
  146. package/dist/services/healthService.js +50 -0
  147. package/dist/services/healthService.js.map +1 -0
  148. package/dist/services/metricsService.d.ts +35 -0
  149. package/dist/services/metricsService.js +57 -0
  150. package/dist/services/metricsService.js.map +1 -0
  151. package/dist/services/rateLimiter.d.ts +23 -0
  152. package/dist/services/rateLimiter.js +45 -0
  153. package/dist/services/rateLimiter.js.map +1 -0
  154. package/dist/services/reviewService.d.ts +32 -0
  155. package/dist/services/reviewService.js +94 -0
  156. package/dist/services/reviewService.js.map +1 -0
  157. package/dist/services/schedulerService.d.ts +30 -0
  158. package/dist/services/schedulerService.js +89 -0
  159. package/dist/services/schedulerService.js.map +1 -0
  160. package/dist/storage/backupService.d.ts +14 -0
  161. package/dist/storage/backupService.js +90 -0
  162. package/dist/storage/backupService.js.map +1 -0
  163. package/dist/storage/database.d.ts +119 -0
  164. package/dist/storage/database.js +935 -0
  165. package/dist/storage/database.js.map +1 -0
  166. package/dist/storage/migrations/001_initial.sql +63 -0
  167. package/dist/storage/migrations/002_discovery_uniqueness.sql +8 -0
  168. package/dist/storage/migrations/003_connector_identity.sql +7 -0
  169. package/dist/storage/migrations/004_claim_context.sql +15 -0
  170. package/dist/storage/migrations/005_claim_history.sql +26 -0
  171. package/dist/storage/migrations/006_contradiction_resolution.sql +27 -0
  172. package/dist/utils/logger.d.ts +20 -0
  173. package/dist/utils/logger.js +48 -0
  174. package/dist/utils/logger.js.map +1 -0
  175. package/package.json +73 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Daksh Srivastava and Contradiction MCP Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,536 @@
1
+ <div align="center">
2
+
3
+ # Contradiction MCP
4
+
5
+ **Autonomous Cross-Source Inconsistency & Contradiction Intelligence Engine for AI Agents**
6
+
7
+ [![CI Pipeline](https://img.shields.io/github/actions/workflow/status/Daksh-create349/Contradiction-MCP/ci.yml?branch=main&label=CI%20Pipeline&logo=githubactions&logoColor=white&style=flat-square)](https://github.com/Daksh-create349/Contradiction-MCP/actions/workflows/ci.yml)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?logo=open-source-initiative&logoColor=white&style=flat-square)](../LICENSE)
9
+ [![Node.js Version](https://img.shields.io/badge/Node.js-%3E%3D20.0.0-339933.svg?logo=node.js&logoColor=white&style=flat-square)](https://nodejs.org/)
10
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178C6.svg?logo=typescript&logoColor=white&style=flat-square)](https://www.typescriptlang.org/)
11
+ [![MCP Specification](https://img.shields.io/badge/MCP-2.0.0-8A2BE2.svg?logo=anthropic&logoColor=white&style=flat-square)](https://modelcontextprotocol.io/)
12
+ [![Vitest Tests](https://img.shields.io/badge/Tests-169%20passed-2ea44f.svg?logo=vitest&logoColor=white&style=flat-square)](tests)
13
+ [![Security Audit](https://img.shields.io/badge/Security-0%20vulnerabilities-brightgreen.svg?style=flat-square)](package.json)
14
+ [![Code Style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?logo=prettier&logoColor=white&style=flat-square)](https://prettier.io/)
15
+
16
+ <p align="center">
17
+ <a href="#the-problem-it-solves">Problem</a> •
18
+ <a href="#core-capabilities">Capabilities</a> •
19
+ <a href="#system-architecture">Architecture</a> •
20
+ <a href="#one-command-quickstart-all-ides">Quickstart</a> •
21
+ <a href="#mcp-interface-21-tools-4-resources-2-prompts">Tools Reference</a> •
22
+ <a href="#step-by-step-hands-on-tutorial">Tutorials</a> •
23
+ <a href="#documentation-index">Docs</a> •
24
+ <a href="#license">License</a>
25
+ </p>
26
+
27
+ </div>
28
+
29
+ ---
30
+
31
+ ## The Problem It Solves
32
+
33
+ Modern engineering ecosystems rely on fragmented, uncoordinated sources of truth:
34
+
35
+ - **Code Repositories**: `package.json`, `Dockerfile`, CI/CD workflows (`.github/workflows/*.yml`)
36
+ - **Deployment Manifests**: Kubernetes YAML, Helm values, cloud environment configurations
37
+ - **Technical Documentation**: Architecture guides, runbooks, developer setup portals, READMEs
38
+ - **Public Endpoints**: OpenAPI/Swagger schemas, status feeds, live web documentation
39
+
40
+ When these systems diverge—for example, a Kubernetes manifest deploying Node.js 22 while technical documentation instructs developers to run Node.js 18, or conflicting database engine versions across staging and production—silent regressions, deploy failures, and hallucinations in LLM reasoning occur.
41
+
42
+ **Contradiction MCP** bridges these silos through automated multi-source ingestion, context-aware contradiction reasoning, source authority and freshness scoring, human-in-the-loop review/resolution workflows, and immutable audit trails.
43
+
44
+ ---
45
+
46
+ ## Core Capabilities
47
+
48
+ - **Zero Mocks**: Real embedded SQLite with Write-Ahead Logging (WAL), real filesystem I/O with directory containment guards, and real HTTP fetchers with pre-flight DNS validation.
49
+ - **Context-Aware Contradiction Engine**: Eliminates false positives by understanding semantic contexts:
50
+ - **Environments**: `production` vs `staging` vs `development`
51
+ - **Scopes**: `file` vs `deployment` vs `cluster`
52
+ - **Roles**: `source_of_truth` vs `deployment` vs `documentation`
53
+ - **Deterministic SemVer Mathematics**: Employs rigorous version range satisfaction algebra rather than naive string comparisons.
54
+ - **Multi-Source Ingestion Pipeline**:
55
+ - **GitHub Connector**: Analyzes runtime engines, Dockerfiles, GitHub Actions workflows, and READMEs.
56
+ - **Document Connector**: Extracts structured claims from JSON, YAML, Markdown, CSV, TXT, and PDF documents with exact page- and line-numbered evidence citations.
57
+ - **Public Website Connector**: Web crawler hardened with multi-layer SSRF protection against loopback, private IPv4/IPv6 CIDRs, and cloud metadata endpoints (`169.254.169.254`).
58
+ - **Scoring & Advisory Intelligence**:
59
+ - `AuthorityScorer`: Ranks conflicting claims based on source hierarchy and origin credibility.
60
+ - `FreshnessScorer`: Applies exponential half-life time decay models.
61
+ - `EvidenceEvaluator`: Quantifies citation directness and snippet quality.
62
+ - `ResolutionAdvisor`: Generates actionable resolution recommendations without mutating state without operator consent.
63
+ - **Review & Resolution Workflows**: Full lifecycle transitions (`OPEN` → `REVIEWED` → `RESOLVED` / `DISMISSED` → `REOPENED`) backed by append-only audit histories.
64
+ - **Dual Transport Architecture**: Operates over standard **Stdio** (for Claude Desktop, Google Antigravity, Cursor) or **Streamable HTTP/SSE** with Bearer API key authentication and sliding rate limiting.
65
+
66
+ ---
67
+
68
+ ## System Architecture
69
+
70
+ ### Visual Dataflow
71
+
72
+ ```mermaid
73
+ flowchart TD
74
+ subgraph Clients["MCP Clients & IDEs"]
75
+ Claude["Claude Desktop"]
76
+ AGY["Google Antigravity"]
77
+ Cursor["Cursor IDE"]
78
+ HTTP["Remote HTTP / SSE"]
79
+ end
80
+
81
+ subgraph Protocol["MCP Protocol Layer"]
82
+ StdioT["StdioServerTransport"]
83
+ HttpT["StreamableHttpTransport"]
84
+ Router["21 Tools | 4 Resources | 2 Prompts"]
85
+ end
86
+
87
+ subgraph Core["Analysis & Intelligence Engine"]
88
+ Engine["ContradictionEngine"]
89
+ Classifier["ContradictionClassifier"]
90
+ Authority["AuthorityScorer"]
91
+ Freshness["FreshnessScorer"]
92
+ Advisor["ResolutionAdvisor"]
93
+ end
94
+
95
+ subgraph Connectors["Ingestion Connectors"]
96
+ GH["GitHub Connector"]
97
+ DOC["Document Connector (PDF/YAML/JSON/MD)"]
98
+ WEB["Website Connector (SSRF Guarded)"]
99
+ end
100
+
101
+ subgraph Storage["Storage Layer"]
102
+ DB[(SQLite WAL Mode)]
103
+ Audit["Immutable Audit Trail"]
104
+ Backups["Online Live Backups"]
105
+ end
106
+
107
+ Claude --> StdioT
108
+ AGY --> StdioT
109
+ Cursor --> StdioT
110
+ HTTP --> HttpT
111
+
112
+ StdioT --> Router
113
+ HttpT --> Router
114
+
115
+ Router --> Engine
116
+ Router --> Connectors
117
+
118
+ Connectors --> DB
119
+ Engine --> Classifier
120
+ Engine --> Authority
121
+ Engine --> Freshness
122
+ Engine --> Advisor
123
+
124
+ Engine --> DB
125
+ DB --> Audit
126
+ DB --> Backups
127
+ ```
128
+
129
+ ---
130
+
131
+ ## One-Command Quickstart (All IDEs)
132
+
133
+ Automatically configure Contradiction MCP into your favorite editor with a single command:
134
+
135
+ ### Universal CLI Setup
136
+
137
+ ```bash
138
+ # Google Antigravity (configured in ~/.gemini/config/mcp_config.json and workspace)
139
+ npx -y contradiction-mcp install antigravity
140
+
141
+ # Cursor IDE (configured in ~/.cursor/mcp.json and workspace)
142
+ npx -y contradiction-mcp install cursor
143
+
144
+ # Claude Desktop App (configured in claude_desktop_config.json)
145
+ npx -y contradiction-mcp install claude
146
+
147
+ # Claude Code CLI (configured in ~/.claude.json & via claude mcp add)
148
+ npx -y contradiction-mcp install claude-code
149
+
150
+ # Windsurf IDE (configured in ~/.codeium/windsurf/mcp_config.json)
151
+ npx -y contradiction-mcp install windsurf
152
+
153
+ # Configure ALL detected IDEs simultaneously
154
+ npx -y contradiction-mcp install all
155
+ ```
156
+
157
+ ### Local Setup from Cloned Source
158
+
159
+ ```bash
160
+ git clone https://github.com/Daksh-create349/Contradiction-MCP.git
161
+ cd "Contradiction MCP/contradiction-mcp"
162
+ npm install
163
+ npm run build
164
+
165
+ # Automatically configure in your current environment:
166
+ npm run install-mcp
167
+
168
+ # Or target a specific IDE:
169
+ node bin/cli.js install [antigravity|cursor|claude|claude-code|windsurf|all]
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Manual IDE Client Configuration
175
+
176
+ If you prefer manual configuration, add the following configuration block to your client settings:
177
+
178
+ ### 1. Claude Desktop (`claude_desktop_config.json`)
179
+
180
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
181
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
182
+ - **Linux**: `~/.config/Claude/claude_desktop_config.json`
183
+
184
+ ```json
185
+ {
186
+ "mcpServers": {
187
+ "contradiction": {
188
+ "command": "node",
189
+ "args": ["/ABSOLUTE/PATH/TO/contradiction-mcp/dist/index.js"],
190
+ "env": {
191
+ "NODE_ENV": "production",
192
+ "DATABASE_PATH": "/ABSOLUTE/PATH/TO/contradiction-mcp/data/contradiction.db",
193
+ "MCP_TRANSPORT": "stdio",
194
+ "LOG_LEVEL": "error"
195
+ }
196
+ }
197
+ }
198
+ }
199
+ ```
200
+
201
+ ### 2. Google Antigravity (`mcp_config.json`)
202
+
203
+ - **Global**: `~/.gemini/config/mcp_config.json`
204
+ - **Workspace**: `<workspace-root>/.agents/mcp_config.json`
205
+
206
+ ```json
207
+ {
208
+ "mcpServers": {
209
+ "contradiction": {
210
+ "command": "node",
211
+ "args": ["/ABSOLUTE/PATH/TO/contradiction-mcp/dist/index.js"],
212
+ "env": {
213
+ "NODE_ENV": "production",
214
+ "DATABASE_PATH": "/ABSOLUTE/PATH/TO/contradiction-mcp/data/contradiction.db",
215
+ "MCP_TRANSPORT": "stdio",
216
+ "LOG_LEVEL": "error"
217
+ }
218
+ }
219
+ }
220
+ }
221
+ ```
222
+
223
+ ### 3. Cursor IDE (`.cursor/mcp.json`)
224
+
225
+ ```json
226
+ {
227
+ "mcpServers": {
228
+ "contradiction": {
229
+ "command": "node",
230
+ "args": ["/ABSOLUTE/PATH/TO/contradiction-mcp/dist/index.js"]
231
+ }
232
+ }
233
+ }
234
+ ```
235
+
236
+ ### 4. Streamable HTTP Remote Client
237
+
238
+ Connect distributed agents or team members to a centralized server daemon:
239
+
240
+ ```json
241
+ {
242
+ "mcpServers": {
243
+ "contradiction": {
244
+ "url": "http://localhost:3000/mcp",
245
+ "headers": {
246
+ "Authorization": "Bearer YOUR_SECRET_API_KEY"
247
+ }
248
+ }
249
+ }
250
+ }
251
+ ```
252
+
253
+ ---
254
+
255
+ ## MCP Interface: 21 Tools, 4 Resources, 2 Prompts
256
+
257
+ ### Active MCP Tools (21)
258
+
259
+ | Tool Name | Description | Key Arguments |
260
+ | :------------------------------ | :---------------------------------------------------------------- | :----------------------------------------- |
261
+ | `health_check` | Checks server runtime health, database latency, and entity counts | `{}` |
262
+ | `analyze_claim_pair` | Runs pairwise contradiction analysis between two claim IDs | `claimIdA`, `claimIdB` |
263
+ | `scan_for_contradictions` | Scans the full knowledge base for conflicting assertions | `limit`, `minSeverity` |
264
+ | `scan_claim_for_contradictions` | Incrementally scans candidate pairs for a specific claim | `claimId` |
265
+ | `list_contradictions` | Lists contradictions filtered by status and severity | `status`, `severity`, `limit` |
266
+ | `get_contradiction` | Retrieves detailed contradiction record with claims and sources | `contradictionId` |
267
+ | `explain_claim_relationship` | Explains contextual factors (env, scope, role, SemVer) | `claimIdA`, `claimIdB` |
268
+ | `advise_resolution` | Heuristically compares authority, freshness, and evidence | `contradictionId` |
269
+ | `review_contradiction` | Transitions contradiction to `REVIEWED` status | `contradictionId`, `reviewedBy`, `notes` |
270
+ | `resolve_contradiction` | Resolves contradiction by selecting canonical claim | `contradictionId`, `resolvedBy`, `reason` |
271
+ | `dismiss_contradiction` | Dismisses false positives or intentional differences | `contradictionId`, `dismissedBy`, `reason` |
272
+ | `reopen_contradiction` | Reopens a previously resolved or dismissed contradiction | `contradictionId`, `reopenedBy`, `reason` |
273
+ | `get_contradiction_history` | Returns chronological, immutable audit trail of transitions | `contradictionId` |
274
+ | `get_claim_history` | Returns value history and supersessions for a specific claim | `externalId` |
275
+ | `list_connectors` | Lists registered ingestion connectors and capabilities | `{}` |
276
+ | `test_github_connection` | Tests GitHub connectivity and rate-limit headroom | `owner`, `repo` |
277
+ | `sync_github_repository` | Ingests package.json, Dockerfile, README, and workflows | `owner`, `repo`, `branch` |
278
+ | `sync_document` | Ingests local JSON, YAML, MD, CSV, TXT, or PDF files | `filePath`, `subject`, `sourceRole` |
279
+ | `sync_website` | Ingests web URL with pre-flight SSRF protection | `url`, `subject`, `maxDepth` |
280
+ | `sync_source` | Synchronizes an existing registered source by ID | `sourceId` |
281
+ | `sync_sources` | Bounded-concurrency batch synchronization | `sourceIds` |
282
+
283
+ ### Active MCP Resources (4)
284
+
285
+ - `health://metrics` — Static snapshot of uptime, tool invocations, and contradiction tallies.
286
+ - `contradiction://{id}` — Dynamic resource returning live contradiction state for a specific ID.
287
+ - `claim://{id}` — Dynamic resource returning factual claim details, context, and provenance.
288
+ - `source://{id}` — Dynamic resource returning source metadata, type, and trust score.
289
+
290
+ ### Active MCP Prompts (2)
291
+
292
+ - `investigate_contradiction` — Interactive prompt guiding contradiction investigation, context analysis, and resolution.
293
+ - `review_source_consistency` — Agent prompt guiding systematic cross-source consistency audits.
294
+
295
+ ---
296
+
297
+ ## Example Tool Payloads & Responses
298
+
299
+ <details>
300
+ <summary><b>1. Ingesting a Document (<code>sync_document</code>)</b></summary>
301
+
302
+ **Request**:
303
+
304
+ ```json
305
+ {
306
+ "filePath": "/tmp/deployment_spec.json",
307
+ "subject": "api-server",
308
+ "scope": "deployment",
309
+ "environment": "production",
310
+ "sourceRole": "deployment"
311
+ }
312
+ ```
313
+
314
+ **Response**:
315
+
316
+ ```json
317
+ {
318
+ "success": true,
319
+ "sourceId": "76be8d2f-1e3b-48fd-922f-1b499251ac2b",
320
+ "claimsCreated": 2,
321
+ "claimsUpdated": 0
322
+ }
323
+ ```
324
+
325
+ </details>
326
+
327
+ <details>
328
+ <summary><b>2. Scanning for Contradictions (<code>scan_for_contradictions</code>)</b></summary>
329
+
330
+ **Request**:
331
+
332
+ ```json
333
+ {}
334
+ ```
335
+
336
+ **Response**:
337
+
338
+ ```json
339
+ {
340
+ "status": "completed",
341
+ "claimsScanned": 4,
342
+ "candidatePairs": 2,
343
+ "contradictionsFound": 1,
344
+ "contradictions": [
345
+ {
346
+ "contradictionType": "VERSION_MISMATCH",
347
+ "severity": "HIGH",
348
+ "confidence": 1.0,
349
+ "explanation": "Both claims describe the node_version for 'api-server'. However, architecture_guide.md reports '18.0.0' while deployment_spec.json reports '22.0.0'. Classified as VERSION_MISMATCH with HIGH severity.",
350
+ "priorityScore": 0.93,
351
+ "contradictionId": "2f1691be-9c1f-4e93-a86a-ef0c0ba54f9d"
352
+ }
353
+ ]
354
+ }
355
+ ```
356
+
357
+ </details>
358
+
359
+ <details>
360
+ <summary><b>3. Resolution Advice (<code>advise_resolution</code>)</b></summary>
361
+
362
+ **Request**:
363
+
364
+ ```json
365
+ {
366
+ "contradictionId": "2f1691be-9c1f-4e93-a86a-ef0c0ba54f9d"
367
+ }
368
+ ```
369
+
370
+ **Response**:
371
+
372
+ ```json
373
+ {
374
+ "recommendedClaimId": "a779fa4b-c680-482c-8f31-daf470aaaab7",
375
+ "recommendedValue": "22.0.0",
376
+ "confidenceScore": 0.88,
377
+ "reasoning": "Claim B represents a higher-confidence candidate for current truth because it carries higher operational authority (0.85 vs 0.65) as deployment configuration and is equally fresh.",
378
+ "authorityScoreA": 0.65,
379
+ "authorityScoreB": 0.85
380
+ }
381
+ ```
382
+
383
+ </details>
384
+
385
+ ---
386
+
387
+ ## Step-by-Step Hands-On Tutorial
388
+
389
+ ### Tutorial: Detecting Real Document Contradictions in 30 Seconds
390
+
391
+ ```bash
392
+ cd contradiction-mcp
393
+
394
+ # 1. Create two contradictory specifications for the same service:
395
+ cat << 'EOF' > /tmp/deployment_spec.json
396
+ {
397
+ "node_version": "22.0.0",
398
+ "database": "postgres-16"
399
+ }
400
+ EOF
401
+
402
+ cat << 'EOF' > /tmp/architecture_guide.md
403
+ # Architecture Guide
404
+ node_version: 18.0.0
405
+ database: postgres-14
406
+ EOF
407
+
408
+ # 2. Run test script to ingest and scan via Stdio MCP client:
409
+ npx tsx -e '
410
+ import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
411
+ import { Client } from "@modelcontextprotocol/client";
412
+
413
+ async function main() {
414
+ const client = new Client({ name: "tester", version: "1.0.0" }, { capabilities: {} });
415
+ await client.connect(new StdioClientTransport({ command: "node", args: ["dist/index.js"] }));
416
+
417
+ // Ingest Deployment Spec (role: deployment)
418
+ await client.callTool({
419
+ name: "sync_document",
420
+ arguments: { filePath: "/tmp/deployment_spec.json", subject: "api-server", sourceRole: "deployment", environment: "production" }
421
+ });
422
+
423
+ // Ingest Architecture Guide (role: documentation)
424
+ await client.callTool({
425
+ name: "sync_document",
426
+ arguments: { filePath: "/tmp/architecture_guide.md", subject: "api-server", sourceRole: "documentation", environment: "production" }
427
+ });
428
+
429
+ // Automatically scan knowledge base
430
+ const scan = await client.callTool({ name: "scan_for_contradictions", arguments: {} });
431
+ console.log("\nDISCOVERED CONTRADICTIONS:\n", JSON.stringify(JSON.parse(scan.content[0].text), null, 2));
432
+
433
+ await client.close();
434
+ }
435
+ main();
436
+ '
437
+ ```
438
+
439
+ ---
440
+
441
+ ## Complete Command Reference
442
+
443
+ | Command | Description |
444
+ | :----------------------- | :--------------------------------------------------------------------------- |
445
+ | `npm run build` | Compiles TypeScript and packages SQL migration scripts |
446
+ | `npm start` | Launches compiled production server (`node dist/index.js`) |
447
+ | `npm run dev` | Runs development server with on-the-fly TypeScript execution |
448
+ | `npm test` | Runs complete Vitest test suite (**169 tests across 23 files**) |
449
+ | `npm run test:coverage` | Generates detailed V8 code coverage report |
450
+ | `npm run verify` | Runs all 62 end-to-end verification gates (protocol, security, heuristics) |
451
+ | `npm run demo` | Executes live 17-step end-to-end demonstration scenario |
452
+ | `npm run smoke` | Launches compiled server and verifies real MCP Stdio connectivity |
453
+ | `npm run live-test` | Runs stdio smoke tests followed by Streamable HTTP integration suite |
454
+ | `npm run typecheck` | Validates TypeScript static typing (`tsc --noEmit`) with 0 errors |
455
+ | `npm run lint` | Lints codebase with ESLint 9 Flat Config (0 errors, 0 warnings) |
456
+ | `npm run format:check` | Verifies code formatting against Prettier |
457
+ | `npm run format` | Auto-formats all code using Prettier |
458
+ | `npm run install-mcp` | Automatically configures MCP settings across Antigravity, Cursor, and Claude |
459
+ | `npm run migrate` | Executes pending SQLite database schema migrations |
460
+ | `npm run seed` | Seeds database with realistic demonstration claims and sources |
461
+ | `npm run backup` | Creates zero-downtime online SQLite backup in `backups/` |
462
+ | `npm run restore <path>` | Restores database from a designated backup archive |
463
+ | `npm run health` | Queries system health status and outputs operational JSON |
464
+ | `npm run security:check` | Runs `npm audit` to inspect dependency security vulnerabilities |
465
+
466
+ ---
467
+
468
+ ## Environment Variables
469
+
470
+ | Variable | Default | Description |
471
+ | :--------------------- | :------------------------ | :----------------------------------------------------------- |
472
+ | `NODE_ENV` | `development` | Runtime mode: `development`, `test`, or `production` |
473
+ | `DATABASE_PATH` | `./data/contradiction.db` | Path to SQLite database file or `:memory:` |
474
+ | `MCP_TRANSPORT` | `stdio` | Transport mode: `stdio` or `http` |
475
+ | `HTTP_PORT` | `3000` | Port for Streamable HTTP server when `MCP_TRANSPORT=http` |
476
+ | `HTTP_HOST` | `127.0.0.1` | Binding address for HTTP daemon (DNS rebinding guarded) |
477
+ | `API_KEY` | _(optional)_ | Secret bearer token required for HTTP authentication |
478
+ | `GITHUB_TOKEN` | _(optional)_ | Personal Access Token to prevent GitHub API rate limits |
479
+ | `LOG_LEVEL` | `error` | Logging level: `debug`, `info`, `warn`, `error` |
480
+ | `ALLOWED_ROOTS` | `.` | Comma-separated directory paths permitted for file ingestion |
481
+ | `MAX_FILE_SIZE_BYTES` | `10485760` (10MB) | Maximum file size allowed for document ingestion |
482
+ | `RATE_LIMIT_MAX` | `100` | Maximum requests permitted per sliding time window |
483
+ | `RATE_LIMIT_WINDOW_MS` | `60000` (1 min) | Sliding rate limiter window in milliseconds |
484
+
485
+ ---
486
+
487
+ ## Docker & Container Deployment
488
+
489
+ ### Run with Docker
490
+
491
+ ```bash
492
+ # Build production container (multi-stage, non-root user):
493
+ docker build -t contradiction-mcp:latest .
494
+
495
+ # Run container with persistent data volume:
496
+ docker run -d \
497
+ --name contradiction-mcp \
498
+ -p 3000:3000 \
499
+ -v contradiction-data:/app/data \
500
+ -e MCP_TRANSPORT=http \
501
+ -e HTTP_PORT=3000 \
502
+ contradiction-mcp:latest
503
+ ```
504
+
505
+ ### Run with Docker Compose
506
+
507
+ ```bash
508
+ docker compose up -d
509
+ docker compose ps
510
+ docker compose logs -f
511
+ ```
512
+
513
+ ---
514
+
515
+ ## Documentation Index
516
+
517
+ - [Architecture Guide](docs/architecture.md) — Layered design, protocol topology, and component contracts.
518
+ - [Security Model](docs/security.md) — Multi-layer SSRF defenses, directory containment, and scope authorizations.
519
+ - [Connectors Reference](docs/connectors.md) — GitHub, Document (PDF/JSON/YAML/CSV/TXT), and Website connectors.
520
+ - [Database & Migrations](docs/database.md) — Schema definitions, audit tables, and WAL configuration.
521
+ - [Operations & Runbook](docs/operations.md) — Online backups, rate limiting, scheduling, and graceful shutdown.
522
+ - [Testing Strategy](docs/testing.md) — Zero-mock philosophy, test suite itemization, and benchmarks.
523
+ - [Practical Examples](docs/examples.md) — Detailed walkthroughs of real-world contradiction scenarios.
524
+
525
+ ---
526
+
527
+ ## License
528
+
529
+ This project is licensed under the **[MIT License](../LICENSE)**.
530
+
531
+ ```text
532
+ MIT License
533
+ Copyright (c) 2026 Daksh Srivastava and Contradiction MCP Contributors
534
+ ```
535
+
536
+ Free and open-source software — you are free to use, modify, distribute, sublicense, and deploy Contradiction MCP in personal and commercial environments.