@context-os/mcp 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@context-os/mcp",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Model Context Protocol server for ContextOS integration",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@modelcontextprotocol/sdk": "^1.6.0",
28
- "@context-os/core": "1.0.0"
28
+ "@context-os/core": "1.0.1"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/chai": "^5.2.3",
@@ -1,88 +0,0 @@
1
- import path from 'node:path';
2
- import fs from 'node:fs';
3
- import { spawn } from 'node:child_process';
4
- /**
5
- * Discovers the workspace root by looking for root/soul.md in parent directories.
6
- */
7
- export function findWorkspaceRoot() {
8
- let current = process.cwd();
9
- const root = path.parse(current).root;
10
- while (current !== root) {
11
- if (fs.existsSync(path.join(current, "root", "soul.md"))) {
12
- return fs.realpathSync(current);
13
- }
14
- current = path.dirname(current);
15
- }
16
- return fs.realpathSync(process.cwd()); // Fallback to CWD
17
- }
18
- export const workspaceRoot = findWorkspaceRoot();
19
- /**
20
- * Standard ContextOS "Buckets" for security isolation.
21
- */
22
- export const ALLOWED_BUCKETS = [
23
- "projects",
24
- "knowledge",
25
- "schemas",
26
- "archive",
27
- "log",
28
- "orgs",
29
- "root"
30
- ];
31
- /**
32
- * Validates that a path is within the workspace root and inside an allowed bucket.
33
- */
34
- export function validatePath(requestedPath) {
35
- const resolvedPath = path.resolve(workspaceRoot, requestedPath);
36
- let fullPath;
37
- try {
38
- fullPath = fs.realpathSync(resolvedPath);
39
- }
40
- catch (e) {
41
- fullPath = resolvedPath;
42
- }
43
- const relativePath = path.relative(workspaceRoot, fullPath);
44
- // Security check: must be within the workspace root
45
- if (relativePath.startsWith("..") || path.isAbsolute(relativePath)) {
46
- throw new Error(`Security violation: Path ${requestedPath} is outside the allowed ContextOS workspace root.`);
47
- }
48
- // Enterprise check: must be within an allowed bucket
49
- const isAllowed = ALLOWED_BUCKETS.some(bucket => {
50
- const bucketRoot = path.join(workspaceRoot, bucket);
51
- const bucketRelative = path.relative(bucketRoot, fullPath);
52
- return !bucketRelative.startsWith("..") && !path.isAbsolute(bucketRelative);
53
- });
54
- if (!isAllowed) {
55
- throw new Error(`Security violation: Path ${requestedPath} is outside the allowed bucket (projects, orgs, knowledge, schemas, etc).`);
56
- }
57
- return { fullPath, relativePath };
58
- }
59
- /**
60
- * Checks if a path is in a read-only bucket for agents.
61
- */
62
- export function isReadOnly(filePath) {
63
- const { fullPath } = validatePath(filePath);
64
- const readOnlyBuckets = ["knowledge", "schemas", "root"];
65
- return readOnlyBuckets.some(bucket => {
66
- const bucketRoot = path.join(workspaceRoot, bucket);
67
- const bucketRelative = path.relative(bucketRoot, fullPath);
68
- return !bucketRelative.startsWith("..") && !path.isAbsolute(bucketRelative);
69
- });
70
- }
71
- /**
72
- * Executes an atomic git transaction (Add + Commit).
73
- */
74
- export async function gitCommit(filePath, message) {
75
- return new Promise((resolve, reject) => {
76
- const add = spawn("git", ["add", filePath], { cwd: workspaceRoot });
77
- add.on("close", (code) => {
78
- if (code !== 0 && code !== null) {
79
- return reject(new Error(`Git add failed with code ${code}`));
80
- }
81
- const commit = spawn("git", ["commit", "-m", message], { cwd: workspaceRoot });
82
- commit.on("close", (code) => {
83
- // If code is not 0, it might be "nothing to commit" which is fine for our tools
84
- resolve();
85
- });
86
- });
87
- });
88
- }
File without changes
File without changes
File without changes