logos-mcp-server 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Logos MCP Server 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,163 @@
1
+ # Logos MCP Server
2
+
3
+ High-resolution structural reasoning and isomorphic mapping for the [Logos Protocol](https://logos.pub).
4
+
5
+ **System Heartbeat: STABLE.**
6
+
7
+ Works with **Cursor**, **Anthropic (Claude Desktop)**, **Antigravity**, and any MCP-compatible client.
8
+
9
+ - **Source:** [github.com/ralphdp/Logos-MCP](https://github.com/ralphdp/Logos-MCP)
10
+ - **License:** MIT
11
+
12
+ ---
13
+
14
+ ## Requirements
15
+
16
+ - **Node.js 18+**
17
+
18
+ ---
19
+
20
+ ## Quick install (one config per client)
21
+
22
+ After adding the config below, **restart your client** so it picks up the server.
23
+
24
+ ### From npm (recommended for npx)
25
+
26
+ If the package is published to npm, use:
27
+
28
+ ```bash
29
+ npx -y logos-mcp-server
30
+ ```
31
+
32
+ In your MCP client: **Command** `npx`, **Args** `-y`, `logos-mcp-server`.
33
+
34
+ ---
35
+
36
+ ### Cursor
37
+
38
+ 1. **Settings** → **Features** → **MCP** → **Add New MCP Server**
39
+ 2. Use either:
40
+
41
+ | Field | Option A (npx from npm or Git) | Option B (local clone) |
42
+ |---------|----------------------------------|------------------------------------|
43
+ | Name | `Logos` | `Logos` |
44
+ | Command | `npx` | `node` |
45
+ | Args | `-y`, `logos-mcp-server` *(npm)*, or `-y`, `git+https://github.com/ralphdp/Logos-MCP.git` *(Git)* | Full path to `build/index.js` (e.g. `/Users/you/Logos-MCP/build/index.js`) |
46
+
47
+ For Option B, run `npm install && npm run build` in the repo first (or just `npm install`; `prepare` runs the build).
48
+
49
+ ---
50
+
51
+ ### Anthropic (Claude Desktop)
52
+
53
+ Edit your MCP config (e.g. `~/Library/Application Support/Claude/claude_desktop_config.json` on macOS) and add:
54
+
55
+ **Option A – npx (from npm or Git):**
56
+ ```json
57
+ "logos": {
58
+ "command": "npx",
59
+ "args": ["-y", "logos-mcp-server"]
60
+ }
61
+ ```
62
+ *(Use `logos-mcp-server` when the package is on npm; or use `"args": ["-y", "git+https://github.com/ralphdp/Logos-MCP.git"]` to run from Git.)*
63
+
64
+ **Option B – local clone:**
65
+ ```json
66
+ "logos": {
67
+ "command": "node",
68
+ "args": ["/ABSOLUTE/PATH/TO/Logos-MCP/build/index.js"]
69
+ }
70
+ ```
71
+
72
+ Put the `logos` entry inside `mcpServers`: `"mcpServers": { "logos": { ... } }`.
73
+
74
+ ---
75
+
76
+ ### Antigravity (Google)
77
+
78
+ Add an MCP server in Antigravity using the same pattern:
79
+
80
+ - **Command:** `npx`
81
+ - **Args:** `-y`, `logos-mcp-server`
82
+
83
+ Or with a local path:
84
+
85
+ - **Command:** `node`
86
+ - **Args:** `/ABSOLUTE/PATH/TO/Logos-MCP/build/index.js`
87
+
88
+ (Exact UI may vary; use “Add MCP server” or equivalent and fill command/args.)
89
+
90
+ ---
91
+
92
+ ## First-time setup (if using this repo directly)
93
+
94
+ ```bash
95
+ git clone https://github.com/ralphdp/Logos-MCP.git
96
+ cd Logos-MCP
97
+ npm install
98
+ npm run build
99
+ ```
100
+
101
+ `prepare` runs `npm run build` on `npm install`, so the server is ready after install. Then use the **local path** in your client config as above.
102
+
103
+ ---
104
+
105
+ ## Provided tools
106
+
107
+ | Tool | Description |
108
+ |--------------------|-------------|
109
+ | `logos_audit` | Structural audit of a claim or text (Logos Triune Canons). |
110
+ | `map_isomorphism` | Structural parallels (isomorphisms) between two domains. |
111
+ | `audit_entropy` | Description length and structural complexity (entropy) of code or text. |
112
+ | `verify_grammar` | Validate code (ALSF); detect “Undefined Behavior” or “Sin”. |
113
+ | `detect_schism` | State deviation in a distributed cluster; enforce Unity. |
114
+ | `system_status` | Logos Kernel invariants status. |
115
+
116
+ ---
117
+
118
+ ## About the Logos Protocol
119
+
120
+ The Logos Protocol defines three invariants (Triune Canons) for structural reasoning and isomorphic mapping. For the full protocol and background, see [logos.pub](https://logos.pub).
121
+
122
+ **Protocol invariants**
123
+
124
+ - **Canon I (Unity):** Every claim must be anchored.
125
+ - **Canon II (Parsimony):** Minimal description length.
126
+ - **Canon III (Recursion):** Self-describing logic.
127
+
128
+ ---
129
+
130
+ ## Development
131
+
132
+ ```bash
133
+ npm install
134
+ npm run build
135
+ npm test
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Troubleshooting
141
+
142
+ - **Server not showing up in my client**
143
+ Restart the client (Cursor, Claude Desktop, or Antigravity) after changing MCP config.
144
+
145
+ - **“Command not found” or similar**
146
+ For **npx**: ensure Node.js 18+ is installed (`node -v`). For **local clone**: use the **full absolute path** to `build/index.js` and run `npm install` (and `npm run build` if needed) in the repo first.
147
+
148
+ - **npx from Git fails**
149
+ Check network access and that the repo URL is correct: `git+https://github.com/ralphdp/Logos-MCP.git`.
150
+
151
+ ---
152
+
153
+ ## Publishing (maintainers)
154
+
155
+ 1. Run `npm pkg fix` so `package.json` matches npm’s expected format (bin path, `repository.url` as `git+https://...`).
156
+ 2. **npm 403 when publishing:** npm requires **two-factor authentication (2FA)** or a **granular access token with “bypass 2FA”** to publish. Enable 2FA at [npmjs.com](https://www.npmjs.com) → Account → Enable 2FA, then run `npm publish` again and enter the one-time code when prompted. Or create an [Access Token](https://www.npmjs.com/access-tokens) with publish permission and use it to log in.
157
+ 3. Then: `npm run build` and `npm publish`.
158
+
159
+ ---
160
+
161
+ ## License
162
+
163
+ MIT — see [LICENSE](LICENSE).
package/build/index.js ADDED
@@ -0,0 +1,174 @@
1
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
4
+ import { ZodError } from "zod";
5
+ import { auditEntropy, detectSchism, logosAudit, mapIsomorphism, systemStatus, verifyGrammar, } from "./tools.js";
6
+ /**
7
+ * LOGOS MCP SERVER
8
+ * An orchestration layer for high-resolution structural reasoning.
9
+ */
10
+ class LogosServer {
11
+ server;
12
+ constructor() {
13
+ this.server = new Server({
14
+ name: "logos-mcp-server",
15
+ version: "1.0.0",
16
+ }, {
17
+ capabilities: {
18
+ tools: {},
19
+ },
20
+ });
21
+ this.setupToolHandlers();
22
+ this.server.onerror = (error) => console.error("[MCP Error]", error);
23
+ process.on("SIGINT", async () => {
24
+ await this.server.close();
25
+ process.exit(0);
26
+ });
27
+ }
28
+ setupToolHandlers() {
29
+ this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
30
+ tools: [
31
+ {
32
+ name: "logos_audit",
33
+ description: "Perform a structural audit of a claim or text using the Logos Triune Canons.",
34
+ inputSchema: {
35
+ type: "object",
36
+ properties: {
37
+ content: {
38
+ type: "string",
39
+ description: "The text or claim to be audited.",
40
+ },
41
+ context: {
42
+ type: "string",
43
+ description: "Optional domain context (e.g. 'Software Engineering', 'Metaphysics').",
44
+ },
45
+ },
46
+ required: ["content"],
47
+ },
48
+ },
49
+ {
50
+ name: "map_isomorphism",
51
+ description: "Identify structural parallels (isomorphisms) between two distinct domains.",
52
+ inputSchema: {
53
+ type: "object",
54
+ properties: {
55
+ source: {
56
+ type: "string",
57
+ description: "The source concept or domain.",
58
+ },
59
+ target: {
60
+ type: "string",
61
+ description: "The target concept or domain to map onto.",
62
+ },
63
+ },
64
+ required: ["source", "target"],
65
+ },
66
+ },
67
+ {
68
+ name: "audit_entropy",
69
+ description: "Measure the description length and structural complexity (entropy) of a code block or text.",
70
+ inputSchema: {
71
+ type: "object",
72
+ properties: {
73
+ content: {
74
+ type: "string",
75
+ description: "The code or text to analyze for entropy.",
76
+ },
77
+ },
78
+ required: ["content"],
79
+ },
80
+ },
81
+ {
82
+ name: "verify_grammar",
83
+ description: "Validate code against a strict formal grammar (ALSF) to detect 'Undefined Behavior' or 'Sin'.",
84
+ inputSchema: {
85
+ type: "object",
86
+ properties: {
87
+ code: {
88
+ type: "string",
89
+ description: "The code block to validate.",
90
+ },
91
+ language: {
92
+ type: "string",
93
+ description: "The programming language or grammar specification.",
94
+ },
95
+ },
96
+ required: ["code", "language"],
97
+ },
98
+ },
99
+ {
100
+ name: "detect_schism",
101
+ description: "Detect state deviation ('Heresy') in a distributed cluster and enforce Unity.",
102
+ inputSchema: {
103
+ type: "object",
104
+ properties: {
105
+ nodes: {
106
+ type: "array",
107
+ items: {
108
+ type: "object",
109
+ properties: {
110
+ id: { type: "string" },
111
+ state_hash: { type: "string" },
112
+ },
113
+ required: ["id", "state_hash"],
114
+ },
115
+ description: "List of nodes with their state hashes.",
116
+ },
117
+ root_hash: {
118
+ type: "string",
119
+ description: "Optional authoritative Root Hash.",
120
+ },
121
+ },
122
+ required: ["nodes"],
123
+ },
124
+ },
125
+ {
126
+ name: "system_status",
127
+ description: "Check the status of the Logos Kernel invariants.",
128
+ inputSchema: {
129
+ type: "object",
130
+ properties: {},
131
+ },
132
+ },
133
+ ],
134
+ }));
135
+ this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
136
+ const { name, arguments: args } = request.params;
137
+ const rawArgs = args ?? {};
138
+ try {
139
+ switch (name) {
140
+ case "logos_audit":
141
+ return logosAudit(rawArgs);
142
+ case "map_isomorphism":
143
+ return mapIsomorphism(rawArgs);
144
+ case "audit_entropy":
145
+ return auditEntropy(rawArgs);
146
+ case "verify_grammar":
147
+ return verifyGrammar(rawArgs);
148
+ case "detect_schism":
149
+ return detectSchism(rawArgs);
150
+ case "system_status":
151
+ return systemStatus();
152
+ default:
153
+ throw new Error(`Unknown tool: ${name}`);
154
+ }
155
+ }
156
+ catch (err) {
157
+ if (err instanceof ZodError) {
158
+ const msg = err.errors
159
+ .map((e) => `${e.path.join(".")}: ${e.message}`)
160
+ .join("; ");
161
+ throw new Error(`Invalid arguments: ${msg}`);
162
+ }
163
+ throw err;
164
+ }
165
+ });
166
+ }
167
+ async run() {
168
+ const transport = new StdioServerTransport();
169
+ await this.server.connect(transport);
170
+ console.error("Logos MCP Server running on stdio");
171
+ }
172
+ }
173
+ const server = new LogosServer();
174
+ server.run().catch(console.error);
@@ -0,0 +1,24 @@
1
+ import { z } from "zod";
2
+ export const LogosAuditArgsSchema = z.object({
3
+ content: z.string().min(1, "content is required"),
4
+ context: z.string().optional(),
5
+ });
6
+ export const MapIsomorphismArgsSchema = z.object({
7
+ source: z.string().min(1, "source is required"),
8
+ target: z.string().min(1, "target is required"),
9
+ });
10
+ export const AuditEntropyArgsSchema = z.object({
11
+ content: z.string().min(1, "content is required"),
12
+ });
13
+ export const VerifyGrammarArgsSchema = z.object({
14
+ code: z.string().min(1, "code is required"),
15
+ language: z.string().min(1, "language is required"),
16
+ });
17
+ export const SchismNodeSchema = z.object({
18
+ id: z.string(),
19
+ state_hash: z.string(),
20
+ });
21
+ export const DetectSchismArgsSchema = z.object({
22
+ nodes: z.array(SchismNodeSchema),
23
+ root_hash: z.string().optional(),
24
+ });
package/build/tools.js ADDED
@@ -0,0 +1,168 @@
1
+ import { AuditEntropyArgsSchema, DetectSchismArgsSchema, LogosAuditArgsSchema, MapIsomorphismArgsSchema, VerifyGrammarArgsSchema, } from "./schemas.js";
2
+ function text(content) {
3
+ return [{ type: "text", text: content }];
4
+ }
5
+ export function logosAudit(args) {
6
+ const { content, context } = LogosAuditArgsSchema.parse(args);
7
+ const ctx = context ?? "Unspecified";
8
+ const hash = Buffer.from(content, "utf8").toString("hex").slice(0, 8);
9
+ return {
10
+ content: text(`[LOGOS AUDIT INITIALIZED]
11
+ Domain: ${ctx}
12
+ Input Hash: ${hash}...
13
+
14
+ I. STRUCTURAL DIAGNOSIS:
15
+ Analyzing '${content}' for internal consistency and anchoring.
16
+
17
+ II. PARSIMONIOUS REDUCTION:
18
+ Stripping rhetorical noise.
19
+
20
+ III. OPERATIONAL DIRECTIVE:
21
+ Awaiting structural verification against the Master Specification.
22
+
23
+ [PROMPT TO LLM: Complete this audit following the Logos Protocol Invariants.]`),
24
+ };
25
+ }
26
+ export function mapIsomorphism(args) {
27
+ const { source, target } = MapIsomorphismArgsSchema.parse(args);
28
+ return {
29
+ content: text(`[ISOMORPHIC SCAN: ${source} ∩ ${target}]
30
+ Objective: Map the structural nodes of ${source} onto the logic of ${target}.
31
+
32
+ PRELIMINARY NODES:
33
+ 1. Origin/Root mapping
34
+ 2. Transform/Execution mapping
35
+ 3. Termination/Halting mapping
36
+
37
+ [PROMPT TO LLM: Generate the Isomorphic Mapping table for these domains.]`),
38
+ };
39
+ }
40
+ export function auditEntropy(args) {
41
+ const { content } = AuditEntropyArgsSchema.parse(args);
42
+ const chars = content.length;
43
+ const tokens = content.split(/\s+/).filter(Boolean).length || 1;
44
+ const complexityScore = Math.round(Math.log2(Math.max(chars, 1)) * tokens);
45
+ const warning = complexityScore > 500
46
+ ? "WARNING: High entropy detected. Canon II violation (Parsimony). Code requires structural compression."
47
+ : "NOMINAL: Code maintains terminal stability.";
48
+ return {
49
+ content: text(`[PNEUMA MONITOR: HARDENED ENTROPY SCAN]
50
+ Protocol: Hardening Section 14 (Parsimony)
51
+ Metrics:
52
+ - Raw Description Length: ${chars} chars
53
+ - Token Count: ${tokens} nodes
54
+ - Formal Complexity D(L): ${complexityScore} bits
55
+
56
+ ANALYSIS:
57
+ ${warning}
58
+
59
+ [PROMPT TO LLM: Apply the Logos Minification Theorem to reduce D(L) while preserving semantic invariants.]`),
60
+ };
61
+ }
62
+ export function verifyGrammar(args) {
63
+ const { code, language } = VerifyGrammarArgsSchema.parse(args);
64
+ const getMaxNesting = (str) => {
65
+ let max = 0, current = 0;
66
+ for (const char of str) {
67
+ if (char === "{")
68
+ current++;
69
+ if (char === "}")
70
+ current--;
71
+ if (current > max)
72
+ max = current;
73
+ }
74
+ return max;
75
+ };
76
+ const forbiddenPatterns = [
77
+ /eval\s*\(/i,
78
+ /Function\s*\(/i,
79
+ /os\.system\s*\(/i,
80
+ /process\.exec\s*\(/i,
81
+ /child_process\./i,
82
+ /SELECT.*FROM.*WHERE.*=.*\+/i,
83
+ ];
84
+ const detectedSins = forbiddenPatterns
85
+ .filter((p) => p.test(code))
86
+ .map((p) => p.source);
87
+ const nesting = getMaxNesting(code);
88
+ const protocolFailure = nesting > 5 || detectedSins.length > 0;
89
+ const status = protocolFailure
90
+ ? "REJECTED: Undefined Behavior / Infinite Descent detected. System security compromised."
91
+ : "ACCEPTED: Structural invariants within terminal limits.";
92
+ return {
93
+ content: text(`[ALSF VALIDATOR: HARDENED NARROW GATE]
94
+ Target Environment: ${language}
95
+ Nesting Depth: ${nesting} (Limit: 5)
96
+ Detected 'Sin' Patterns: ${detectedSins.length > 0 ? detectedSins.join(", ") : "NONE"}
97
+
98
+ FILTER STATUS:
99
+ ${status}
100
+
101
+ [PROMPT TO LLM: If REJECTED, audit the provided code for violation of the Master Specification and suggest a well-founded refactor.]`),
102
+ };
103
+ }
104
+ export function detectSchism(args) {
105
+ const parsed = DetectSchismArgsSchema.parse(args);
106
+ const { nodes, root_hash } = parsed;
107
+ const totalNodes = nodes.length;
108
+ if (totalNodes === 0) {
109
+ return {
110
+ content: text(`[CONSENSUS AUDITOR: SCHISM SCAN]
111
+ Method: N/A (empty cluster)
112
+ Standard Hash: N/A
113
+
114
+ CLUSTER STATUS:
115
+ - Total Nodes: 0
116
+ - Faithful: 0
117
+ - Heretics: 0
118
+
119
+ DIAGNOSIS:
120
+ No nodes provided. Supply a non-empty nodes array (and optionally root_hash) to run a schism scan.
121
+
122
+ OPERATIONAL DIRECTIVE:
123
+ ACTION: Provide node list to audit.`),
124
+ };
125
+ }
126
+ let standardHash;
127
+ let method;
128
+ if (root_hash) {
129
+ standardHash = root_hash;
130
+ method = "ROOT_AUTHORITY";
131
+ }
132
+ else {
133
+ const counts = {};
134
+ for (const n of nodes) {
135
+ counts[n.state_hash] = (counts[n.state_hash] ?? 0) + 1;
136
+ }
137
+ const keys = Object.keys(counts);
138
+ standardHash = keys.reduce((a, b) => (counts[a] > counts[b] ? a : b));
139
+ method = "DISTRIBUTED_CONSENSUS";
140
+ }
141
+ const heretics = nodes.filter((n) => n.state_hash !== standardHash);
142
+ const faithful = nodes.filter((n) => n.state_hash === standardHash);
143
+ const schismDetected = heretics.length > 0;
144
+ const hashPreview = standardHash.length >= 8 ? `${standardHash.slice(0, 8)}...` : standardHash;
145
+ return {
146
+ content: text(`[CONSENSUS AUDITOR: SCHISM SCAN]
147
+ Method: ${method}
148
+ Standard Hash: ${hashPreview}
149
+
150
+ CLUSTER STATUS:
151
+ - Total Nodes: ${totalNodes}
152
+ - Faithful: ${faithful.length}
153
+ - Heretics: ${heretics.length}
154
+
155
+ DIAGNOSIS:
156
+ ${schismDetected ? `CRITICAL: SCHISM DETECTED. ${heretics.length} nodes have deviated from the Truth.` : "UNIFIED: The Body is One."}
157
+
158
+ OPERATIONAL DIRECTIVE:
159
+ ${schismDetected ? `ACTION: EXCOMMUNICATE or RECONCILE the following nodes: ${heretics.map((n) => n.id).join(", ")}` : "ACTION: MAINTAIN UNITY."}
160
+
161
+ [PROMPT TO LLM: If SCHISM DETECTED, propose a re-sync strategy to restore the stray nodes to the Standard Hash.]`),
162
+ };
163
+ }
164
+ export function systemStatus() {
165
+ return {
166
+ content: text("System Heartbeat: LOCKED\nProtocol: ACTIVE\nInvariants: SATISFIED (Unity, Parsimony, Recursion)"),
167
+ };
168
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "logos-mcp-server",
3
+ "version": "1.0.0",
4
+ "description": "An MCP server for high-resolution structural reasoning under the Logos Protocol.",
5
+ "main": "build/index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "logos-mcp-server": "build/index.js"
9
+ },
10
+ "files": [
11
+ "build",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/ralphdp/Logos-MCP.git"
18
+ },
19
+ "homepage": "https://github.com/ralphdp/Logos-MCP#readme",
20
+ "bugs": {
21
+ "url": "https://github.com/ralphdp/Logos-MCP/issues"
22
+ },
23
+ "license": "MIT",
24
+ "keywords": [
25
+ "mcp",
26
+ "model-context-protocol",
27
+ "logos",
28
+ "cursor",
29
+ "claude",
30
+ "antigravity",
31
+ "structural-reasoning"
32
+ ],
33
+ "scripts": {
34
+ "prepare": "npm run build",
35
+ "build": "tsc",
36
+ "start": "node build/index.js",
37
+ "dev": "ts-node src/index.ts",
38
+ "test": "vitest run",
39
+ "test:watch": "vitest"
40
+ },
41
+ "dependencies": {
42
+ "@modelcontextprotocol/sdk": "^1.26.0",
43
+ "zod": "^3.23.0"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^20.0.0",
47
+ "typescript": "^5.0.0",
48
+ "vitest": "^4.0.0"
49
+ }
50
+ }