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
5 changes: 5 additions & 0 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
"./virtual": {
"types": "./dist/virtual.d.mts",
"import": "./dist/virtual.mjs"
},
"./mcp": {
"types": "./dist/mcp-entry.d.mts",
"import": "./dist/mcp-entry.mjs"
}
},
"publishConfig": {
Expand Down Expand Up @@ -123,6 +127,7 @@
"oxfmt": "^0.19.0",
"picocolors": "^1.1.1",
"tinyglobby": "^0.2.15",
"@modelcontextprotocol/sdk": "^1.12.1",
"trpc-cli": "^0.12.1",
"ts-morph": "^27.0.2",
"yaml": "^2.8.3",
Expand Down
9 changes: 6 additions & 3 deletions apps/cli/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { createBtsCli } from "./index";

createBtsCli().run();
const firstArg = process.argv[2];
if (firstArg === "mcp" && process.argv.length === 3) {
import("./mcp.js").then((m) => m.startMcpServer());
} else {
import("./index.js").then((m) => m.createBtsCli().run());
}
17 changes: 14 additions & 3 deletions apps/cli/src/helpers/addons/addons-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { setupTui } from "./tui-setup";
import { setupUltracite } from "./ultracite-setup";
import { setupWxt } from "./wxt-setup";

export async function setupAddons(config: ProjectConfig) {
export async function setupAddons(config: ProjectConfig): Promise<string[]> {
const warnings: string[] = [];
const { addons, frontend, projectDir } = config;
const hasReactWebFrontend =
frontend.includes("react-router") ||
Expand Down Expand Up @@ -95,12 +96,22 @@ export async function setupAddons(config: ProjectConfig) {
}

if (addons.includes("mcp")) {
await setupMcp(config);
try {
await setupMcp(config);
} catch (error) {
warnings.push(`MCP setup failed: ${error instanceof Error ? error.message : String(error)}`);
}
}

if (addons.includes("skills")) {
await setupSkills(config);
try {
await setupSkills(config);
} catch (error) {
warnings.push(`Skills setup failed: ${error instanceof Error ? error.message : String(error)}`);
}
}

return warnings;
}

export async function setupBiome(projectDir: string) {
Expand Down
7 changes: 6 additions & 1 deletion apps/cli/src/helpers/core/add-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface AddResult {
addedAddons: Addons[];
projectDir: string;
error?: string;
setupWarnings?: string[];
}

export async function addHandler(
Expand Down Expand Up @@ -169,7 +170,7 @@ async function addHandlerInternal(input: AddInput): Promise<AddResult> {

await writeTreeToFilesystem(tree, projectDir);

await setupAddons(config);
const setupWarnings = await setupAddons(config);
await applyDependencyVersionChannel(projectDir, config.versionChannel);

const updatedAddons = [...new Set([...existingAddons, ...addonsToAdd])];
Expand Down Expand Up @@ -197,6 +198,9 @@ async function addHandlerInternal(input: AddInput): Promise<AddResult> {

if (!isSilent()) {
log.success(pc.green(`Successfully added: ${addonsToAdd.join(", ")}`));
for (const warning of setupWarnings) {
log.warn(pc.yellow(warning));
}
if (!input.install) {
const installCmd =
config.packageManager === "npm" ? "npm install" : `${config.packageManager} install`;
Expand All @@ -209,6 +213,7 @@ async function addHandlerInternal(input: AddInput): Promise<AddResult> {
success: true,
addedAddons: addonsToAdd,
projectDir,
setupWarnings: setupWarnings.length > 0 ? setupWarnings : undefined,
};
}

Expand Down
6 changes: 6 additions & 0 deletions apps/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ export const router = os.router({
ecosystem: input.ecosystem,
});
}),
mcp: os
.meta({ description: "Start MCP server for AI agent integration (stdio transport)" })
.handler(async () => {
log.message("MCP server is started via the 'mcp' subcommand intercepted in cli.ts.");
log.message("Run: create-better-fullstack mcp");
}),
});

const caller = createRouterClient(router, { context: {} });
Expand Down
3 changes: 3 additions & 0 deletions apps/cli/src/mcp-entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { startMcpServer } from "./mcp.js";

startMcpServer();
Loading
Loading