Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"@fiberplane/mcp-gateway-types",
"@fiberplane/mcp-gateway-core",
"@fiberplane/mcp-gateway-server",
"@fiberplane/mcp-gateway-cli"
"@fiberplane/mcp-gateway-cli",
"@fiberplane/mcp-gateway-api"
],
"packages": ["packages/*"]
}
8 changes: 1 addition & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,4 @@ jobs:
run: bun run lint

- name: Build packages
run: |
bun run --filter @fiberplane/mcp-gateway-web build
bun run --filter @fiberplane/mcp-gateway-types build
bun run --filter @fiberplane/mcp-gateway-core build
bun run --filter @fiberplane/mcp-gateway-api build
bun run --filter @fiberplane/mcp-gateway-server build
bun run --filter @fiberplane/mcp-gateway-cli build
run: bun run build
36 changes: 8 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ permissions:
id-token: write

jobs:
# Check and build library packages (types, core, server)
# Build the libraries
build-libs:
name: Build library packages
name: Build packages
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -37,36 +37,13 @@ jobs:
- name: Lint
run: bun run lint

- name: Build library packages
run: |
bun run --filter @fiberplane/mcp-gateway-types build
bun run --filter @fiberplane/mcp-gateway-core build
bun run --filter @fiberplane/mcp-gateway-server build

# Build CLI source package
build-cli:
name: Build CLI package
runs-on: ubuntu-latest
needs: build-libs
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Build CLI package
run: bun run --filter @fiberplane/mcp-gateway-cli build
- name: Build all packages
run: bun run build

# Build platform-specific binaries
build-binaries:
name: Build ${{ matrix.platform }} binary
needs: build-cli
needs: build-libs
strategy:
matrix:
include:
Expand All @@ -87,6 +64,9 @@ jobs:
- name: Install dependencies
run: bun install --frozen-lockfile --verbose

- name: Build web and CLI packages
run: bun run --filter @fiberplane/mcp-gateway-web build && bun run --filter @fiberplane/mcp-gateway-cli build

- name: Build binary for ${{ matrix.platform }}
run: bun run build:binaries

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ packages/mcp-gateway/src/version.ts
# Binary packages (compiled executables)
packages/mcp-gateway-*/mcp-gateway
packages/mcp-gateway-*/mcp-gateway.exe
packages/mcp-gateway-*/public
packages/mcp-gateway-*/drizzle

deps.svg
9 changes: 5 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ This is a Bun workspace monorepo containing the MCP Gateway project. The reposit
### Development Commands
- `bun install` - Install all workspace dependencies
- `bun run dev` - Start development mode (filters to CLI package)
- `bun run build` - Build CLI package (filters to main package)
- `bun run build` - Build all packages in dependency order (types → core → api → server → web → cli)
- `bun run build:binaries` - Build platform-specific binaries (current platform or --all)
- `bun run clean` - Clean all dist folders
- `bun test` - Run all tests across workspace
- `bun run typecheck` - Type check all packages
- `bun run lint` - Lint all files
- `bun run format` - Format all files
- `bun run check-circular` - Check for circular dependencies
- `bun run lint` - Lint all files with Biome
- `bun run format` - Format all files with Biome
- `bun run check-circular` - Check for circular dependencies (both within and between packages)
- `bun run deps-graph` - Generate dependency graph (deps.svg)

### Package-Specific Commands
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
],
"scripts": {
"dev": "bun run --filter @fiberplane/mcp-gateway-cli dev",
"build": "bun run --filter @fiberplane/mcp-gateway-cli build",
"build": "bun run --filter @fiberplane/mcp-gateway-types build && bun run --filter @fiberplane/mcp-gateway-core build && bun run --filter @fiberplane/mcp-gateway-api build && bun run --filter @fiberplane/mcp-gateway-server build && bun run --filter @fiberplane/mcp-gateway-web build && bun run --filter @fiberplane/mcp-gateway-cli build",
"build:types": "bun run --filter @fiberplane/mcp-gateway-cli build:types",
"build:binaries": "bun run scripts/build-binaries.ts",
"clean": "rm -rf packages/*/dist",
"test": "bun test",
"typecheck": "bun run --filter '*' typecheck",
"lint": "biome ci .",
"format": "biome check --write .",
"check-circular": "madge --circular --extensions ts,tsx packages/*/src",
"deps-graph": "madge --image deps.svg --extensions ts,tsx packages/*/src",
"check-circular": "madge --circular --extensions ts,tsx --ts-config ./tsconfig.madge.json packages/*/src",
"deps-graph": "madge --image deps.svg --extensions ts,tsx --ts-config ./tsconfig.madge.json packages/*/src",
"changeset": "changeset",
"release": "changeset publish",
"ci:version": "changeset version && bun update",
Expand Down
27 changes: 26 additions & 1 deletion packages/core/src/logs/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,31 @@ let migrationPromise: Promise<void> | null = null;
* Works in both development and production builds
*/
function getMigrationsFolder(): string {
// Detect if we're running as a compiled binary
// In compiled binaries, Bun.main starts with "/$bunfs/root/" (virtual bundled filesystem)
const isCompiledBinary = Bun.main.startsWith("/$bunfs/root/");

if (isCompiledBinary) {
// In compiled binary: migrations are in drizzle/ folder next to executable
const binaryDrizzleDir = join(process.execPath, "..", "drizzle");
const journalPath = join(binaryDrizzleDir, "meta", "_journal.json");

try {
const journalFile = Bun.file(journalPath);
if (journalFile.size > 0) {
return binaryDrizzleDir;
}
} catch {
throw new Error(
`Migrations folder not found in binary distribution at: ${binaryDrizzleDir}`,
);
}

throw new Error(
`Invalid migrations folder in binary distribution at: ${binaryDrizzleDir}`,
);
}

// In development: packages/core/src/logs/migrations.ts
// Migrations are in: packages/core/drizzle
const currentFile = fileURLToPath(import.meta.url);
Expand Down Expand Up @@ -45,7 +70,7 @@ export async function ensureMigrations(
migrationPromise = (async () => {
try {
const migrationsFolder = getMigrationsFolder();
await migrate(db, { migrationsFolder });
migrate(db, { migrationsFolder });
} catch (err) {
// Reset promise to allow retry
migrationPromise = null;
Expand Down
4 changes: 3 additions & 1 deletion packages/mcp-gateway-darwin-arm64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"arm64"
],
"files": [
"mcp-gateway"
"mcp-gateway",
"public",
"drizzle"
],
"publishConfig": {
"access": "public"
Expand Down
4 changes: 3 additions & 1 deletion packages/mcp-gateway-linux-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.4.2",
"description": "MCP Gateway binary for linux-x64 (placeholder - overwritten by build)",
"files": [
"mcp-gateway"
"mcp-gateway",
"public",
"drizzle"
],
"publishConfig": {
"access": "public"
Expand Down
12 changes: 11 additions & 1 deletion scripts/build-binaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,24 @@ mcp-gateway.exe
await $`chmod +x ${pkgDir}/mcp-gateway`;
}

// Copy public folder with web UI files
const publicSrc = "./packages/cli/public";
const publicDest = join(pkgDir, "public");
await $`cp -r ${publicSrc} ${publicDest}`;

// Copy drizzle migrations folder
const drizzleSrc = "./packages/core/drizzle";
const drizzleDest = join(pkgDir, "drizzle");
await $`cp -r ${drizzleSrc} ${drizzleDest}`;

// Create package.json
const pkgJson = {
name: `@fiberplane/mcp-gateway-${platform.name}`,
version: VERSION,
description: `MCP Gateway binary for ${platform.os}-${platform.cpu}`,
os: [platform.os],
cpu: [platform.cpu],
files: [`mcp-gateway${platform.ext}`],
files: [`mcp-gateway${platform.ext}`, "public", "drizzle"],
publishConfig: {
access: "public",
},
Expand Down
17 changes: 17 additions & 0 deletions tsconfig.madge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"paths": {
"@fiberplane/mcp-gateway-types": ["./packages/types/src/index.ts"],
"@fiberplane/mcp-gateway-types/*": ["./packages/types/src/*"],
"@fiberplane/mcp-gateway-core": ["./packages/core/src/index.ts"],
"@fiberplane/mcp-gateway-core/*": ["./packages/core/src/*"],
"@fiberplane/mcp-gateway-api": ["./packages/api/src/index.ts"],
"@fiberplane/mcp-gateway-api/*": ["./packages/api/src/*"],
"@fiberplane/mcp-gateway-server": ["./packages/server/src/index.ts"],
"@fiberplane/mcp-gateway-server/*": ["./packages/server/src/*"],
"@fiberplane/mcp-gateway-cli": ["./packages/mcp-gateway/src/index.ts"],
"@fiberplane/mcp-gateway-cli/*": ["./packages/mcp-gateway/src/*"]
}
}
}