Browse the blog

Your MCP Codebase Just Hit 50 Files. Here's How to Stop the Chaos.

  • frontmcp
  • mcp
  • nx
  • monorepo

Here's a scenario you might recognize:

You built an MCP server with FrontMCP. It started clean — a few tools, a resource, maybe an agent. Thirty files. Everything in one project. Life was good.

Then the second team needed tools. Then the third. Someone copy-pasted shared-utils.ts into a new folder. Someone else wrote a duplicate auth provider. You now have:

  • 50+ files with no clear boundaries
  • Copy-pasted utilities drifting out of sync
  • No build caching — every change rebuilds everything
  • No dependency graph — breaking changes are discovered in production
  • One deployment target — but staging needs different apps than production

You don't need a bigger project. You need a monorepo.


Introducing @frontmcp/nx

@frontmcp/nx is the official Nx plugin for FrontMCP. It brings monorepo-scale development to MCP servers with everything you need to organize, build, and deploy multi-app platforms.

16 Generators

Scaffold workspaces, apps, libraries, servers, and 12 component types — all following FrontMCP conventions.

7 Executors

Build, dev, serve, test, inspect, and deploy — all integrated with Nx caching and dependency ordering.

3-Layer Architecture

Servers → Apps → Libs. Clean separation of infrastructure, business logic, and shared code.

Multi-Platform Deploy

Generate deployment shells for Node/Docker, Vercel, Lambda, and Cloudflare — each composing different app combinations.


The Scaling Problem

Every FrontMCP project starts standalone. And for a single server with one team, standalone is perfect. But teams grow, tools multiply, and suddenly you're fighting your own codebase.

StandaloneMonorepo
Projects1Many (apps, libs, servers)
Code sharingCopy-pasteImport from shared libs
Build cachingNoneNx caches unchanged projects
Dependency trackingManualNx dependency graph
Affected testingRun everythingnx affected -t test
Deployment targets1Multiple servers per environment
Team boundariesConventionsEnforced via tags + module boundaries

Three-Layer Architecture

The Nx plugin organizes your codebase into three distinct layers, each with a clear responsibility:

LayerDirectoryContainsDepends On
Serversservers/Entry points, Docker/Vercel/Lambda configApps, Libs
Appsapps/Tools, resources, prompts, skills, agentsLibs
Libslibs/Shared utilities, plugins, adaptersOther Libs

5-Minute Quickstart

Go from zero to a running multi-app MCP server inside an Nx monorepo:

  1. Create the workspace

    npx frontmcp create my-platform --nx
    cd my-platform

    This scaffolds the full monorepo structure with Nx configuration, TypeScript path aliases, and a sample app.

  2. Generate an app

    nx g @frontmcp/nx:app crm

    Creates apps/crm/ with a main entry point, app class, and sample tool.

  3. Add tools and agents

    nx g @frontmcp/nx:tool fetch-contacts --project crm
    nx g @frontmcp/nx:agent lead-qualifier --project crm

    Generators follow FrontMCP conventions — decorators, Zod schemas, and proper file placement.

  4. Create a shared library

    nx g @frontmcp/nx:lib shared-utils

    Creates libs/shared-utils/ — import it from any app via workspace path aliases.

  5. Generate a server

    nx g @frontmcp/nx:server production --apps crm --deploymentTarget node

    Creates servers/production/ with a Dockerfile, docker-compose.yml, and an entry point that composes the CRM app.

  6. Start development

    nx dev crm

    Hot-reload development mode. Edit tools, resources, or agents and see changes instantly.

  7. Build and deploy

    nx build production

    Compiles the production server to servers/production/dist/ — ready for Docker, Vercel, Lambda, or Cloudflare.


What Gets Generated

After the quickstart, your workspace looks like this:

my-platform/
├── apps/
│   └── crm/
│       ├── src/
│       │   ├── main.ts
│       │   ├── crm.app.ts
│       │   ├── tools/
│       │   │   ├── hello.tool.ts
│       │   │   └── fetch-contacts.tool.ts
│       │   └── agents/
│       │       └── lead-qualifier.agent.ts
│       ├── project.json
│       └── tsconfig.json
├── libs/
│   └── shared-utils/
│       ├── src/
│       │   ├── shared-utils.ts
│       │   └── index.ts
│       └── project.json
├── servers/
│   └── production/
│       ├── src/main.ts
│       ├── Dockerfile
│       ├── docker-compose.yml
│       └── project.json
├── nx.json
├── tsconfig.base.json
└── package.json

The generated server entry point composes your apps:

servers/production/src/main.ts
import { FrontMcp } from '@frontmcp/sdk';
import { CrmApp } from '@apps/crm';

@FrontMcp({
  info: { name: 'Production', version: '1.0.0' },
  apps: [CrmApp],
})
export default class Server {}

And the generated app registers tools, resources, and agents:

apps/crm/src/crm.app.ts
import { App } from '@frontmcp/sdk';
import { HelloTool } from './tools/hello.tool';
import { FetchContactsTool } from './tools/fetch-contacts.tool';
import { LeadQualifierAgent } from './agents/lead-qualifier.agent';

@App({
  id: 'crm',
  name: 'CRM',
  tools: [HelloTool, FetchContactsTool],
  agents: [LeadQualifierAgent],
})
export class CrmApp {}

16 Generators

Every generator follows FrontMCP conventions and produces code with the correct decorator, Zod schemas, and file placement.

Structural Generators

These create top-level projects in your monorepo:

GeneratorDescriptionOutput
workspaceScaffold a full Nx monorepoRoot directory
appGenerate a FrontMCP applicationapps/<name>/
libGenerate a shared librarylibs/<name>/
serverGenerate a deployment shellservers/<name>/

Component Generators

These add components to existing projects:

GeneratorOutputDecorator
toolsrc/tools/<name>.tool.ts@Tool
resourcesrc/resources/<name>.resource.ts@Resource
promptsrc/prompts/<name>.prompt.ts@Prompt
skillsrc/skills/<name>.skill.ts@Skill
agentsrc/agents/<name>.agent.ts@Agent
providersrc/providers/<name>.provider.ts@Provider
pluginsrc/plugins/<name>.plugin.ts@Plugin
adaptersrc/adapters/<name>.adapter.ts@Adapter
auth-providersrc/auth/<name>.auth-provider.ts@AuthProvider
flowsrc/flows/<name>.flow.ts@Flow
jobsrc/jobs/<name>.job.ts@Job
workflowsrc/workflows/<name>.workflow.ts@Workflow

Run any generator with:

nx g @frontmcp/nx:<generator> <name> --project <app>

7 Executors

Executors wrap FrontMCP CLI commands as Nx targets, enabling caching, dependency ordering, and nx affected support.

ExecutorCLI CommandCacheableLong-Running
buildfrontmcp buildYesNo
build-execfrontmcp build --execYesNo
devfrontmcp devNoYes
servefrontmcp startNoYes
testfrontmcp testYesNo
inspectorfrontmcp inspectorNoYes
deployPlatform-specificNoNo

Why Nx Executors Matter

Build Caching

Unchanged projects skip builds entirely. Nx restores cached output in milliseconds.

Dependency Ordering

nx run-many -t build builds projects in correct dependency order automatically.

Affected Commands

nx affected -t test only tests projects impacted by your changes. CI goes from 10 minutes to 30 seconds.

Executors are configured in each project's project.json:

apps/crm/project.json
{
  "name": "crm",
  "targets": {
    "build": {
      "executor": "@frontmcp/nx:build",
      "outputs": ["{projectRoot}/dist"],
      "options": {
        "entry": "{projectRoot}/src/main.ts",
        "outputPath": "{projectRoot}/dist"
      }
    },
    "dev": {
      "executor": "@frontmcp/nx:dev",
      "options": {
        "entry": "{projectRoot}/src/main.ts"
      }
    },
    "test": {
      "executor": "@frontmcp/nx:test",
      "options": {
        "runInBand": true
      }
    }
  }
}

Multi-Platform Deployment

Generate deployment shells targeting different platforms — each composing different app combinations:

nx g @frontmcp/nx:server production --apps crm,analytics --deploymentTarget node

Generates a Dockerfile, docker-compose.yml, and entry point:

servers/production/
├── src/main.ts
├── Dockerfile
├── docker-compose.yml
└── project.json

Build and run:

nx build production
docker compose -f servers/production/docker-compose.yml up

Real-World Scenario: 3 Teams, 1 Platform

Imagine you're building an internal AI platform. Three teams contribute tools:

  • CRM team — lead management, contact sync, pipeline tools
  • Analytics team — dashboards, reports, data queries
  • Admin team — user management, billing, configuration

Here's how you'd set it up:

# Create the workspace
npx frontmcp create internal-platform --nx
cd internal-platform

# Generate apps for each team
nx g @frontmcp/nx:app crm --tags "scope:crm,type:app"
nx g @frontmcp/nx:app analytics --tags "scope:analytics,type:app"
nx g @frontmcp/nx:app admin --tags "scope:admin,type:app"

# Generate shared libraries
nx g @frontmcp/nx:lib shared-utils --tags "scope:shared,type:lib"
nx g @frontmcp/nx:lib auth-helpers --tags "scope:shared,type:lib"

# Add tools to each app
nx g @frontmcp/nx:tool fetch-leads --project crm
nx g @frontmcp/nx:tool sync-contacts --project crm
nx g @frontmcp/nx:tool generate-report --project analytics
nx g @frontmcp/nx:tool manage-users --project admin

# Generate servers for different environments
nx g @frontmcp/nx:server production --apps crm,analytics --deploymentTarget node
nx g @frontmcp/nx:server staging --apps crm,analytics,admin --deploymentTarget node
nx g @frontmcp/nx:server edge --apps crm --deploymentTarget vercel

Now your CI pipeline can use nx affected to only build and test what changed:

# CI pipeline
nx affected -t test      # Only test affected projects
nx affected -t build     # Only build affected projects
nx affected -t deploy    # Only deploy affected servers

One change to shared-utils triggers tests for all three apps — but only builds the two servers that actually changed. The edge server (which doesn't use shared-utils) is skipped entirely.


Migration from Standalone

Already have a standalone FrontMCP project? Here's how to migrate:

  1. Create the workspace

    npx frontmcp create my-platform --nx
    cd my-platform
  2. Generate an app for your existing code

    nx g @frontmcp/nx:app my-app
  3. Copy your source files

    cp -r ../my-standalone/src/tools/* apps/my-app/src/tools/
    cp -r ../my-standalone/src/resources/* apps/my-app/src/resources/
    cp -r ../my-standalone/src/prompts/* apps/my-app/src/prompts/

    Update apps/my-app/src/my-app.app.ts to import all your components.

  4. Extract shared code into libraries

    nx g @frontmcp/nx:lib shared-utils
    nx g @frontmcp/nx:lib data-models

    Move shared utilities into libs/ and update imports.

  5. Update imports to workspace aliases

    // Before (relative)
    import { formatDate } from '../../utils/format';
    
    // After (workspace alias)
    import { formatDate } from '@my-platform/shared-utils';
  6. Generate a server

    nx g @frontmcp/nx:server production --apps my-app --deploymentTarget node
  7. Verify everything works

    nx dev my-app          # Development mode
    nx build production    # Build
    nx test my-app         # Tests
    nx graph               # Visualize dependencies

Standalone vs Monorepo Comparison

FeatureStandaloneMonorepo with @frontmcp/nx
Setupnpx frontmcp createnpx frontmcp create --nx
Code sharingCopy-paste between projectsImport from libs/
Build cachingNoneNx caches unchanged projects
Dependency graphManual trackingnx graph — visual + enforced
Affected testingRun all testsnx affected -t test
Deployment targets1 server configMultiple servers per environment
Team boundariesHonor systemTags + module boundary rules
Component generatorsfrontmcp generatenx g @frontmcp/nx:<generator>
Build commandfrontmcp buildnx build <project> (cached)
Dev modefrontmcp devnx dev <app>
CI optimizationBuild everythingBuild only what changed

Essential Commands

CommandDescription
nx g @frontmcp/nx:app <name>Generate a new app
nx g @frontmcp/nx:lib <name>Generate a shared library
nx g @frontmcp/nx:server <name>Generate a deployment shell
nx g @frontmcp/nx:tool <name> --project <app>Add a tool to an app
nx dev <app>Start dev mode with hot-reload
nx build <project>Build an app or server
nx test <project>Run tests
nx inspector <app>Launch MCP Inspector
nx graphVisualize dependency graph
nx affected -t testTest only affected projects
nx run-many -t buildBuild all projects

Get Started


@frontmcp/nx is part of the FrontMCP ecosystem. Combine it with CodeCall for code-execution at scale, Tool UI for rich widgets, and deploy to any platform with a single command.

Star us on GitHub to follow development.

Code in this post targets the FrontMCP version current when it was written; see Versions for what changed since.