@fractary/codex-mcp 0.9.0 → 0.10.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/README.md CHANGED
@@ -37,7 +37,7 @@ Add to your `.claude/settings.json`:
37
37
  "mcpServers": {
38
38
  "fractary-codex": {
39
39
  "command": "npx",
40
- "args": ["-y", "@fractary/codex-mcp-server", "--config", ".fractary/codex/config.yaml"]
40
+ "args": ["-y", "@fractary/codex-mcp-server", "--config", ".fractary/config.yaml"]
41
41
  }
42
42
  }
43
43
  }
@@ -46,7 +46,7 @@ Add to your `.claude/settings.json`:
46
46
  ### Stdio Mode (Default)
47
47
 
48
48
  ```bash
49
- fractary-codex-mcp --config .fractary/codex/config.yaml
49
+ fractary-codex-mcp --config .fractary/config.yaml
50
50
  ```
51
51
 
52
52
  The server communicates via stdin/stdout using the MCP protocol.
@@ -61,7 +61,7 @@ The server exposes an SSE (Server-Sent Events) endpoint for HTTP clients.
61
61
 
62
62
  ## Configuration
63
63
 
64
- Create a `.fractary/codex/config.yaml` configuration file:
64
+ Create a `.fractary/config.yaml` configuration file:
65
65
 
66
66
  ```yaml
67
67
  # Organization configuration
@@ -139,7 +139,7 @@ const result = await fetch('codex://fractary/auth-service/specs/WORK-123.md')
139
139
 
140
140
  ### Environment Variables
141
141
 
142
- - `FRACTARY_CONFIG`: Path to configuration file (default: `.fractary/codex/config.yaml`)
142
+ - `FRACTARY_CONFIG`: Path to configuration file (default: `.fractary/config.yaml`)
143
143
  - `GITHUB_TOKEN`: GitHub personal access token for GitHub storage provider
144
144
  - `FRACTARY_CLI`: Path to fractary CLI executable (default: `fractary`)
145
145
  - `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`: AWS credentials for S3
@@ -304,7 +304,7 @@ If you were using the MCP server from `@fractary/codex` (versions ≤0.1.x), upd
304
304
  "mcpServers": {
305
305
  "fractary-codex": {
306
306
  "command": "npx",
307
- "args": ["@fractary/codex", "mcp", "--config", ".fractary/codex/config.yaml"]
307
+ "args": ["@fractary/codex", "mcp", "--config", ".fractary/config.yaml"]
308
308
  }
309
309
  }
310
310
  }
@@ -316,7 +316,7 @@ If you were using the MCP server from `@fractary/codex` (versions ≤0.1.x), upd
316
316
  "mcpServers": {
317
317
  "fractary-codex": {
318
318
  "command": "npx",
319
- "args": ["-y", "@fractary/codex-mcp-server", "--config", ".fractary/codex/config.yaml"]
319
+ "args": ["-y", "@fractary/codex-mcp-server", "--config", ".fractary/config.yaml"]
320
320
  }
321
321
  }
322
322
  }
package/dist/cli.cjs CHANGED
@@ -12687,8 +12687,40 @@ var ArchiveProjectConfigSchema = external_exports.object({
12687
12687
  var ArchiveConfigSchema = external_exports.object({
12688
12688
  projects: external_exports.record(ArchiveProjectConfigSchema)
12689
12689
  });
12690
+ var GitHubAuthConfigSchema = external_exports.object({
12691
+ /** Default token environment variable name (default: GITHUB_TOKEN) */
12692
+ default_token_env: external_exports.string().optional(),
12693
+ /** Fallback to public access if authentication fails */
12694
+ fallback_to_public: external_exports.boolean().optional()
12695
+ });
12696
+ var AuthConfigSchema = external_exports.object({
12697
+ /** GitHub authentication configuration */
12698
+ github: GitHubAuthConfigSchema.optional()
12699
+ });
12700
+ var SourceConfigSchema = external_exports.object({
12701
+ /** Source type */
12702
+ type: external_exports.enum(["github", "s3", "http", "local"]),
12703
+ /** Environment variable containing the authentication token */
12704
+ token_env: external_exports.string().optional(),
12705
+ /** Direct token value (not recommended, use token_env instead) */
12706
+ token: external_exports.string().optional(),
12707
+ /** Branch to fetch from (for GitHub sources) */
12708
+ branch: external_exports.string().optional(),
12709
+ /** Base URL (for HTTP sources) */
12710
+ base_url: external_exports.string().optional(),
12711
+ /** Bucket name (for S3 sources) */
12712
+ bucket: external_exports.string().optional(),
12713
+ /** Prefix/path within bucket (for S3 sources) */
12714
+ prefix: external_exports.string().optional()
12715
+ });
12716
+ var DependencyConfigSchema = external_exports.object({
12717
+ /** Sources within this dependency */
12718
+ sources: external_exports.record(SourceConfigSchema)
12719
+ });
12690
12720
  var CodexConfigSchema = external_exports.object({
12691
12721
  organizationSlug: external_exports.string(),
12722
+ /** Project name (optional) */
12723
+ project: external_exports.string().optional(),
12692
12724
  directories: external_exports.object({
12693
12725
  source: external_exports.string().optional(),
12694
12726
  target: external_exports.string().optional(),
@@ -12698,7 +12730,11 @@ var CodexConfigSchema = external_exports.object({
12698
12730
  // Directional sync configuration
12699
12731
  sync: DirectionalSyncSchema.optional(),
12700
12732
  // Archive configuration
12701
- archive: ArchiveConfigSchema.optional()
12733
+ archive: ArchiveConfigSchema.optional(),
12734
+ // Authentication configuration
12735
+ auth: AuthConfigSchema.optional(),
12736
+ // Dependencies configuration (external projects)
12737
+ dependencies: external_exports.record(DependencyConfigSchema).optional()
12702
12738
  }).strict();
12703
12739
  var FileSourceSchema = external_exports.object({
12704
12740
  type: external_exports.enum(["s3", "r2", "gcs", "local"]),
@@ -13692,7 +13728,9 @@ var S3ArchiveStorage = class {
13692
13728
  var StorageManager = class {
13693
13729
  providers = /* @__PURE__ */ new Map();
13694
13730
  priority;
13731
+ codexConfig;
13695
13732
  constructor(config = {}) {
13733
+ this.codexConfig = config.codexConfig;
13696
13734
  this.providers.set("local", new LocalStorage(config.local));
13697
13735
  this.providers.set("github", new GitHubStorage(config.github));
13698
13736
  this.providers.set("http", new HttpStorage(config.http));
@@ -13704,6 +13742,48 @@ var StorageManager = class {
13704
13742
  }
13705
13743
  this.priority = config.priority || (config.filePlugin && config.s3Archive ? ["file-plugin", "local", "s3-archive", "github", "http"] : config.filePlugin ? ["file-plugin", "local", "github", "http"] : config.s3Archive ? ["local", "s3-archive", "github", "http"] : ["local", "github", "http"]);
13706
13744
  }
13745
+ /**
13746
+ * Resolve authentication token for a reference
13747
+ *
13748
+ * Looks up dependency-specific authentication or falls back to default
13749
+ */
13750
+ resolveToken(reference) {
13751
+ if (!this.codexConfig) {
13752
+ return void 0;
13753
+ }
13754
+ const dependencyKey = `${reference.org}/${reference.project}`;
13755
+ if (this.codexConfig.dependencies?.[dependencyKey]) {
13756
+ const dependency = this.codexConfig.dependencies[dependencyKey];
13757
+ for (const [, sourceConfig] of Object.entries(dependency.sources)) {
13758
+ if (sourceConfig.type === "github") {
13759
+ if (sourceConfig.token_env) {
13760
+ const token = process.env[sourceConfig.token_env];
13761
+ if (token) {
13762
+ return token;
13763
+ }
13764
+ }
13765
+ if (sourceConfig.token) {
13766
+ return sourceConfig.token;
13767
+ }
13768
+ }
13769
+ }
13770
+ }
13771
+ const defaultTokenEnv = this.codexConfig.auth?.github?.default_token_env || "GITHUB_TOKEN";
13772
+ return process.env[defaultTokenEnv];
13773
+ }
13774
+ /**
13775
+ * Resolve fetch options with authentication
13776
+ *
13777
+ * Merges reference-specific authentication with provided options
13778
+ */
13779
+ resolveFetchOptions(reference, options) {
13780
+ const token = this.resolveToken(reference);
13781
+ return {
13782
+ ...options,
13783
+ token: options?.token || token
13784
+ // Explicit option overrides resolved token
13785
+ };
13786
+ }
13707
13787
  /**
13708
13788
  * Register a custom storage provider
13709
13789
  */
@@ -13744,8 +13824,10 @@ var StorageManager = class {
13744
13824
  * Fetch content for a reference
13745
13825
  *
13746
13826
  * Tries providers in priority order until one succeeds.
13827
+ * Automatically resolves authentication based on dependency configuration.
13747
13828
  */
13748
13829
  async fetch(reference, options) {
13830
+ const resolvedOptions = this.resolveFetchOptions(reference, options);
13749
13831
  const errors = [];
13750
13832
  for (const type2 of this.priority) {
13751
13833
  const provider = this.providers.get(type2);
@@ -13753,7 +13835,7 @@ var StorageManager = class {
13753
13835
  continue;
13754
13836
  }
13755
13837
  try {
13756
- return await provider.fetch(reference, options);
13838
+ return await provider.fetch(reference, resolvedOptions);
13757
13839
  } catch (error) {
13758
13840
  errors.push(error instanceof Error ? error : new Error(String(error)));
13759
13841
  }
@@ -13774,15 +13856,17 @@ var StorageManager = class {
13774
13856
  * Check if content exists for a reference
13775
13857
  *
13776
13858
  * Returns true if any provider reports the content exists.
13859
+ * Automatically resolves authentication based on dependency configuration.
13777
13860
  */
13778
13861
  async exists(reference, options) {
13862
+ const resolvedOptions = this.resolveFetchOptions(reference, options);
13779
13863
  for (const type2 of this.priority) {
13780
13864
  const provider = this.providers.get(type2);
13781
13865
  if (!provider || !provider.canHandle(reference)) {
13782
13866
  continue;
13783
13867
  }
13784
13868
  try {
13785
- if (await provider.exists(reference, options)) {
13869
+ if (await provider.exists(reference, resolvedOptions)) {
13786
13870
  return true;
13787
13871
  }
13788
13872
  } catch {
@@ -13802,6 +13886,8 @@ var StorageManager = class {
13802
13886
  }
13803
13887
  /**
13804
13888
  * Fetch multiple references in parallel
13889
+ *
13890
+ * Automatically resolves authentication for each reference based on dependency configuration.
13805
13891
  */
13806
13892
  async fetchMany(references, options) {
13807
13893
  const results = /* @__PURE__ */ new Map();
@@ -14984,14 +15070,23 @@ function expandEnvVars(obj) {
14984
15070
  return obj;
14985
15071
  }
14986
15072
  var program2 = new Command();
14987
- program2.name("fractary-codex-mcp").description("MCP server for Fractary Codex knowledge management").version("0.8.0").option("--config <path>", "Path to config file", ".fractary/codex/config.yaml").action(async (options) => {
15073
+ program2.name("fractary-codex-mcp").description("MCP server for Fractary Codex knowledge management").version("0.8.0").option("--config <path>", "Path to config file", ".fractary/config.yaml").action(async (options) => {
14988
15074
  let config = {};
14989
15075
  try {
14990
15076
  const configFile = (0, import_fs.readFileSync)(options.config, "utf-8");
14991
- config = load(configFile);
15077
+ const rawConfig = load(configFile);
15078
+ if (rawConfig && typeof rawConfig === "object" && "codex" in rawConfig) {
15079
+ config = {
15080
+ ...rawConfig.codex,
15081
+ // Preserve file section if present (for file plugin integration)
15082
+ file: rawConfig.file
15083
+ };
15084
+ } else {
15085
+ config = rawConfig || {};
15086
+ }
14992
15087
  config = expandEnvVars(config);
14993
15088
  } catch (error) {
14994
- if (options.config !== ".fractary/codex/config.yaml") {
15089
+ if (options.config !== ".fractary/config.yaml") {
14995
15090
  console.error(`Warning: Could not load config file: ${options.config}`);
14996
15091
  }
14997
15092
  }