maven-indexer-mcp 1.0.3 → 1.0.4

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/build/config.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import fs from 'fs/promises';
2
+ import { createWriteStream } from 'fs';
2
3
  import path from 'path';
3
4
  import os from 'os';
5
+ import https from 'https';
4
6
  import xml2js from 'xml2js';
5
7
  import { fileURLToPath } from 'url';
6
8
  export class Config {
@@ -74,6 +76,16 @@ export class Config {
74
76
  const __dirname = path.dirname(__filename);
75
77
  this.cfrPath = path.resolve(__dirname, '../lib/cfr-0.152.jar');
76
78
  }
79
+ if (this.cfrPath && !(await this.fileExists(this.cfrPath))) {
80
+ try {
81
+ console.error(`CFR jar not found at ${this.cfrPath}, attempting to download...`);
82
+ await this.downloadCfr(this.cfrPath);
83
+ console.error(`Successfully downloaded CFR jar to ${this.cfrPath}`);
84
+ }
85
+ catch (e) {
86
+ console.error(`Failed to download CFR jar: ${e.message}`);
87
+ }
88
+ }
77
89
  // Log to stderr so it doesn't interfere with MCP protocol on stdout
78
90
  console.error(`Using local repository: ${this.localRepository}`);
79
91
  console.error(`Using Java binary: ${this.javaBinary}`);
@@ -91,6 +103,41 @@ export class Config {
91
103
  const dir = path.dirname(this.javaBinary);
92
104
  return path.join(dir, 'javap');
93
105
  }
106
+ async downloadCfr(destPath) {
107
+ const url = "https://github.com/tangcent/maven-indexer-mcp/raw/refs/heads/main/lib/cfr-0.152.jar";
108
+ const dir = path.dirname(destPath);
109
+ await fs.mkdir(dir, { recursive: true });
110
+ return new Promise((resolve, reject) => {
111
+ const download = (currentUrl) => {
112
+ https.get(currentUrl, (response) => {
113
+ if (response.statusCode === 301 || response.statusCode === 302) {
114
+ if (response.headers.location) {
115
+ download(response.headers.location);
116
+ return;
117
+ }
118
+ }
119
+ if (response.statusCode !== 200) {
120
+ reject(new Error(`Failed to download CFR jar: Status Code ${response.statusCode}`));
121
+ return;
122
+ }
123
+ const file = createWriteStream(destPath);
124
+ response.pipe(file);
125
+ file.on('finish', () => {
126
+ // @ts-ignore
127
+ file.close();
128
+ resolve();
129
+ });
130
+ file.on('error', (err) => {
131
+ fs.unlink(destPath).catch(() => { });
132
+ reject(err);
133
+ });
134
+ }).on('error', (err) => {
135
+ reject(err);
136
+ });
137
+ };
138
+ download(url);
139
+ });
140
+ }
94
141
  async fileExists(filePath) {
95
142
  try {
96
143
  await fs.access(filePath);
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maven-indexer-mcp",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "MCP server for indexing local Maven repository",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
@@ -9,6 +9,7 @@
9
9
  },
10
10
  "files": [
11
11
  "build",
12
+ "lib",
12
13
  "README.md",
13
14
  "LICENSE"
14
15
  ],