Skip to content
Open
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
17 changes: 5 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM amazoncorretto:11-alpine
FROM amazoncorretto:17-alpine

LABEL maintainer="ANTLR4 MCP Server"
LABEL description="Model Context Protocol server for ANTLR4 grammar validation and analysis"
LABEL description="Model Context Protocol server v0.2.0 for ANTLR4 grammar validation and analysis"
LABEL version="0.2.0"

# Create non-root user for security
RUN addgroup -g 1000 antlr && \
Expand All @@ -13,24 +14,16 @@ WORKDIR /app
RUN apk add --no-cache bash

# Copy application files with proper ownership
COPY --chown=antlr:antlr target/antlr4-mcp-server-0.1.0.jar /app/app.jar
COPY --chown=antlr:antlr target/antlr4-mcp-server-0.2.0.jar /app/app.jar
COPY --chown=antlr:antlr src/main/resources/application.yml /app/application.yml

# Create temp directory with restricted permissions
RUN mkdir -p /tmp/antlr && \
chown antlr:antlr /tmp/antlr && \
chmod 700 /tmp/antlr

# Set resource limits for JVM
ENV JAVA_OPTS="-Xms128m -Xmx256m -XX:MaxMetaspaceSize=128m -XX:+UseG1GC -XX:MaxGCPauseMillis=100"
ENV JAVA_OPTS="-Xms128m -Xmx512m -XX:MaxMetaspaceSize=128m -XX:+UseG1GC -XX:MaxGCPauseMillis=100"

# Security: Run as non-root user
USER antlr

# Remove port exposure - MCP uses stdio, not network
# EXPOSE 8080 - REMOVED

# Add temp directory configuration
# Note: Java Security Manager is disabled by default (deprecated in Java 17+)
# Security is now controlled via application.yml (antlr.security.*)
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -Djava.io.tmpdir=/tmp/antlr -jar /app/app.jar"]
41 changes: 30 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ANTLR4 MCP Server
# ANTLR4 MCP Server v0.2.0

> Enable AI assistants to help you develop ANTLR4 grammars through natural conversation

Expand Down Expand Up @@ -65,38 +65,57 @@ cd antlr4-mcp-server
./docker/build.sh
```

2. **Configure Claude Desktop**:
2. **Configure Your AI Assistant**:

Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
#### For Claude Desktop

Edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):

```json
{
"mcpServers": {
"antlr": {
"antlr4": {
"command": "docker",
"args": ["run", "-i", "--rm", "antlr4-mcp-server:latest"]
"args": ["run", "-i", "--rm", "antlr4-mcp-server:0.2.0"]
}
}
}
```

3. **Restart Claude Desktop** - Done! 🎉
#### For Cursor AI

### Configure Cursor IDE

Add to Cursor MCP settings:
Edit `~/.config/cursor/config.json` (macOS/Linux) or `%APPDATA%\Cursor\config.json` (Windows):

```json
{
"mcpServers": {
"antlr": {
"antlr4": {
"command": "docker",
"args": ["run", "-i", "--rm", "antlr4-mcp-server:latest"]
"args": ["run", "-i", "--rm", "antlr4-mcp-server:0.2.0"]
}
}
}
```

#### Alternative: Use JAR Directly (No Docker)

For Claude Desktop or Cursor, if you prefer not using Docker:

```json
{
"mcpServers": {
"antlr4": {
"command": "java",
"args": ["-jar", "/absolute/path/to/antlr4-mcp-server/target/antlr4-mcp-server-0.2.0.jar"]
}
}
}
```

**Important**: Use absolute paths, not relative!

3. **Restart Your AI Assistant** - Done! 🎉

---

## Usage Examples
Expand Down
10 changes: 5 additions & 5 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/bin/bash
set -e

echo "Building ANTLR4 MCP Server Docker image..."
echo "Building ANTLR4 MCP Server v0.2.0 Docker image..."

cd "$(dirname "$0")/.."

echo "Step 1: Building Maven artifact..."
mvn clean package -DskipTests
./mvnw clean package -DskipTests

echo "Step 2: Building Docker image..."
docker build -t antlr4-mcp-server:0.1.0-M1 .
docker tag antlr4-mcp-server:0.1.0-M1 antlr4-mcp-server:latest
docker build -t antlr4-mcp-server:0.2.0 .
docker tag antlr4-mcp-server:0.2.0 antlr4-mcp-server:latest

echo "Build complete!"
echo "Image: antlr4-mcp-server:0.1.0-M1"
echo "Image: antlr4-mcp-server:0.2.0"
echo "Image: antlr4-mcp-server:latest"
8 changes: 1 addition & 7 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#!/bin/bash

echo "Running ANTLR4 MCP Server..."
echo "Running ANTLR4 MCP Server v0.2.0..."

# Run with security constraints
# - No port exposure (removed -p 8080:8080)
# - Memory limits
# - Read-only root filesystem
# - No new privileges
# - Temp directory mounted
docker run -it --rm \
--name antlr4-mcp-server \
--memory="512m" \
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

<groupId>com.github.sshailabh.antlr4mcp</groupId>
<artifactId>antlr4-mcp-server</artifactId>
<version>0.1.0</version>
<version>0.2.0</version>
<packaging>jar</packaging>

<name>ANTLR4 MCP Server</name>
<description>Model Context Protocol server for ANTLR4 grammar validation, parsing, and analysis</description>
<description>Production-ready MCP server for ANTLR4 grammar validation, parsing, and analysis</description>
<url>https://github.com/sshailabh/antlr4-mcp-server</url>

<licenses>
Expand Down
Loading