Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
30 changes: 14 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
# Generated by https://smithery.ai. See: https://smithery.ai/docs/config#dockerfile
# Use a Node.js image as the base
FROM node:22.12-alpine AS builder
# Multi-stage build for Business Central MCP Server (HTTP mode)
FROM node:22-alpine AS builder

# Set the working directory inside the container
# Set working directory
WORKDIR /app

# Copy package.json and package-lock.json to the container
# Copy package files
COPY package.json package-lock.json ./

# Copy the source files needed for build
# Copy source files for build
COPY src ./src
COPY tsconfig.json ./

# Install dependencies (this will also run the prepare script)
# Install dependencies and build
RUN --mount=type=cache,target=/root/.npm npm install

# Build the application
RUN npm run build

# Use a lightweight Node.js image for the final build
# Production image
FROM node:22-alpine

# Set the working directory inside the container
# Set working directory
WORKDIR /app

# Copy the build output and node_modules from the builder stage
# Copy built files and production dependencies
COPY --from=builder /app/build ./build
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package*.json ./

# Don't set default environment variables to ensure proper tool discovery
# These should be provided at runtime
# Expose HTTP server port
EXPOSE 3000

# Specify the command to run the application
ENTRYPOINT ["node", "build/index.js"]
# Run HTTP server (not STDIO)
CMD ["node", "build/http-server.js"]
77 changes: 70 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Model Context Protocol (MCP) server for Microsoft Dynamics 365 Business Central.

- βœ… **Correct API URLs**: Uses proper `/companies(id)/resource` format (no ODataV4 segment)
- βœ… **Zero Installation**: Run with `npx` - no pre-installation required
- βœ… **Azure CLI Auth**: Leverages existing Azure CLI authentication
- βœ… **Flexible Authentication**: Azure CLI for local dev, Managed Identity for cloud deployments
- βœ… **Dual Transport**: STDIO for local use, HTTP for cloud deployments
- βœ… **Cloud Ready**: Docker support for Azure Container Apps and Smithery
- βœ… **Clean Tool Names**: No prefixes, just `get_schema`, `list_items`, etc.
- βœ… **Full CRUD**: Create, read, update, and delete Business Central records

Expand All @@ -29,8 +31,7 @@ No installation needed! Configure in Claude Desktop or Claude Code:
"args": ["/c", "npx", "-y", "@knowall-ai/mcp-business-central"],
"env": {
"BC_URL_SERVER": "https://api.businesscentral.dynamics.com/v2.0/{tenant-id}/{environment}/api/v2.0",
"BC_COMPANY": "Your Company Name",
"BC_AUTH_TYPE": "azure_cli"
"BC_COMPANY": "Your Company Name"
}
}
}
Expand All @@ -47,8 +48,47 @@ Install via [Smithery](https://smithery.ai):
npx -y @smithery/cli install @knowall-ai/mcp-business-central --client claude
```

### Azure Container Apps Deployment

Deploy as an HTTP server for Azure AI Foundry or other cloud services:

1. **Build and push Docker image:**

```bash
docker build -t your-registry.azurecr.io/bc-mcp:latest .
docker push your-registry.azurecr.io/bc-mcp:latest
```

2. **Create Container App:**

```bash
az containerapp create \
--name bc-mcp-server \
--resource-group your-rg \
--environment your-env \
--image your-registry.azurecr.io/bc-mcp:latest \
--target-port 3000 \
--ingress external \
--env-vars \
BC_URL_SERVER="https://api.businesscentral.dynamics.com/v2.0/{tenant}/{environment}/api/v2.0" \
BC_COMPANY="Your Company Name" \
--registry-server your-registry.azurecr.io \
--system-assigned
```

3. **Assign Managed Identity permissions:**

Grant the container app's managed identity access to Business Central APIs in Azure AD.

4. **Use the MCP endpoint:**

The server exposes:
- `/mcp` - MCP protocol endpoint (POST)
- `/health` - Health check endpoint (GET)

### Local Development

**STDIO mode (for Claude Desktop/Code):**
```bash
git clone https://github.com/knowall-ai/mcp-business-central.git
cd mcp-business-central
Expand All @@ -57,6 +97,13 @@ npm run build
node build/index.js
```

**HTTP mode (for testing cloud deployment):**
```bash
npm run build
npm run start:http
# Server runs at http://localhost:3000/mcp
```

## Configuration

### Environment Variables
Expand All @@ -65,7 +112,7 @@ node build/index.js
|----------|----------|-------------|---------|
| `BC_URL_SERVER` | Yes | Business Central API base URL | `https://api.businesscentral.dynamics.com/v2.0/{tenant}/Production/api/v2.0` |
| `BC_COMPANY` | Yes | Company display name | `KnowAll Ltd` |
| `BC_AUTH_TYPE` | No | Authentication type (default: `azure_cli`) | `azure_cli` |
| `PORT` | No | HTTP server port (default: 3000) | `3000` |

### Getting Your Configuration Values

Expand All @@ -78,12 +125,28 @@ Example URL format:
https://api.businesscentral.dynamics.com/v2.0/00000000-0000-0000-0000-000000000000/Production/api/v2.0
```

## Prerequisites
## Authentication

The server uses **DefaultAzureCredential** which automatically tries multiple authentication methods:

- **Azure CLI**: Must be installed and authenticated
### Local Development (STDIO mode)
- **Azure CLI**: Recommended for local development
- Install: https://docs.microsoft.com/cli/azure/install-azure-cli
- Login: `az login`
- Get token: `az account get-access-token --resource https://api.businesscentral.dynamics.com`
- Test: `az account get-access-token --resource https://api.businesscentral.dynamics.com`

### Cloud Deployment (HTTP mode)
- **Managed Identity**: Automatically used when deployed to Azure Container Apps
- No credentials needed in code
- Assign the container app's managed identity permissions to Business Central APIs

### Alternative Methods
DefaultAzureCredential also supports:
- Environment variables (service principal credentials)
- Visual Studio authentication
- VS Code authentication

The credential tries each method in order until one succeeds.

## Available Tools

Expand Down
Loading