Skip to content

Commit 89cbb7e

Browse files
committed
fix: add missing extract-schemas.ts to fix CI build
The extract-schemas.ts file was missing from git because scripts/*.ts files were not whitelisted in .gitignore, causing CI builds to fail. Changes: - Added !scripts/*.ts to .gitignore whitelist - Added !scripts/*.sh to catch all shell scripts - Committed extract-schemas.ts (required for build) - Committed rename-to-micro.sh This fixes the CI failure where tsx couldn't find extract-schemas.ts during the build process. Fixes: CI run #19021965518
1 parent 25f6cba commit 89cbb7e

3 files changed

Lines changed: 118 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ yarn-error.log*
7272
# Scripts directory (development files not for release)
7373
scripts/
7474
!scripts/*.cjs
75+
!scripts/*.ts
76+
!scripts/*.sh
7577
!scripts/cleanup/
7678
!scripts/test-*.js
7779
!scripts/test-*.sh

scripts/extract-schemas.ts

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Extract schemas from SimpleMCP .ts files and save as .schema.json
4+
* Run this during build to preserve parameter information in packaged DXT
5+
*/
6+
7+
import { SchemaExtractor } from '../src/internal-mcps/schema-extractor.js';
8+
import * as fs from 'fs/promises';
9+
import * as path from 'path';
10+
import { fileURLToPath } from 'url';
11+
12+
const __filename = fileURLToPath(import.meta.url);
13+
const __dirname = path.dirname(__filename);
14+
15+
async function extractSchemasForFile(sourceFile: string): Promise<void> {
16+
try {
17+
const extractor = new SchemaExtractor();
18+
const schemas = await extractor.extractFromFile(sourceFile);
19+
20+
if (schemas.length === 0) {
21+
console.log(`⚠️ No schemas extracted from ${path.basename(sourceFile)}`);
22+
return;
23+
}
24+
25+
// Save schemas as .schema.json alongside the source file
26+
const schemaFile = sourceFile.replace(/\.ts$/, '.schema.json');
27+
await fs.writeFile(schemaFile, JSON.stringify(schemas, null, 2));
28+
29+
console.log(`✅ Extracted ${schemas.length} schemas from ${path.basename(sourceFile)} -> ${path.basename(schemaFile)}`);
30+
} catch (error: any) {
31+
console.error(`❌ Failed to extract schemas from ${sourceFile}: ${error.message}`);
32+
}
33+
}
34+
35+
async function findSimpleMCPFiles(dir: string): Promise<string[]> {
36+
const files: string[] = [];
37+
38+
try {
39+
const entries = await fs.readdir(dir, { withFileTypes: true });
40+
41+
for (const entry of entries) {
42+
const fullPath = path.join(dir, entry.name);
43+
44+
if (entry.isDirectory()) {
45+
// Recursively search subdirectories
46+
const subFiles = await findSimpleMCPFiles(fullPath);
47+
files.push(...subFiles);
48+
} else if (entry.isFile() && entry.name.endsWith('.micro.ts')) {
49+
files.push(fullPath);
50+
}
51+
}
52+
} catch (error) {
53+
// Directory doesn't exist, skip
54+
}
55+
56+
return files;
57+
}
58+
59+
async function main() {
60+
console.log('🔍 Extracting schemas from SimpleMCP files...\n');
61+
62+
const projectRoot = path.join(__dirname, '..');
63+
const searchDirs = [
64+
path.join(projectRoot, 'src/internal-mcps/examples'),
65+
// Add more directories if needed
66+
];
67+
68+
let totalSchemas = 0;
69+
70+
for (const dir of searchDirs) {
71+
console.log(`\nSearching ${dir}...`);
72+
const mcpFiles = await findSimpleMCPFiles(dir);
73+
74+
for (const file of mcpFiles) {
75+
await extractSchemasForFile(file);
76+
totalSchemas++;
77+
}
78+
}
79+
80+
console.log(`\n✅ Schema extraction complete! Processed ${totalSchemas} files.`);
81+
}
82+
83+
main().catch((error) => {
84+
console.error('Fatal error:', error);
85+
process.exit(1);
86+
});

scripts/rename-to-micro.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
# Script to rename SimpleMCP to MicroMCP throughout the codebase
3+
4+
set -e
5+
6+
echo "🔄 Renaming SimpleMCP → MicroMCP throughout codebase..."
7+
8+
# Find all TypeScript files in src/ and replace text
9+
find src -name "*.ts" -type f -exec sed -i '' 's/SimpleMCP/MicroMCP/g' {} +
10+
find src -name "*.ts" -type f -exec sed -i '' "s/simple-mcp-adapter/micro-adapter/g" {} +
11+
find src -name "*.ts" -type f -exec sed -i '' "s/simple-mcp-loader/micro-loader/g" {} +
12+
find src -name "*.ts" -type f -exec sed -i '' "s/base-mcp/base-micro/g" {} +
13+
find src -name "*.ts" -type f -exec sed -i '' "s/\.mcp\.ts/.micro.ts/g" {} +
14+
find src -name "*.ts" -type f -exec sed -i '' "s/\.mcp\.js/.micro.js/g" {} +
15+
find src -name "*.ts" -type f -exec sed -i '' "s/\.mcp\.schema\.json/.micro.schema.json/g" {} +
16+
find src -name "*.ts" -type f -exec sed -i '' "s/'\.mcp\.'/'\.micro\.'/g" {} +
17+
find src -name "*.ts" -type f -exec sed -i '' 's/"\.mcp\."/"\.micro\."/g' {} +
18+
19+
# Update references to "Micro Base" back to proper comment
20+
find src -name "*.ts" -type f -exec sed -i '' 's/\* Micro Base Class/\* MicroMCP Base Class/g' {} +
21+
22+
# Update script files
23+
find scripts -name "*.ts" -type f -exec sed -i '' "s/\.mcp\.ts/.micro.ts/g" {} +
24+
find scripts -name "*.ts" -type f -exec sed -i '' "s/\.mcp\.schema\.json/.micro.schema.json/g" {} +
25+
26+
# Update package.json
27+
sed -i '' 's/\.mcp\.schema\.json/.micro.schema.json/g' package.json
28+
sed -i '' 's/internal-mcps\/examples\/\*\.mcp\./internal-mcps\/examples\/\*\.micro\./g' package.json
29+
30+
echo "✅ Renaming complete!"

0 commit comments

Comments
 (0)