Skip to main content
Glama
ahueber

SiLA MCP Server

by ahueber
README.md
# SiLA MCP Server

A Model Context Protocol (MCP) server that acts as a bridge between Claude (or other MCP clients) and an existing SiLA server controlling lab devices.

## Overview

This MCP server exposes laboratory device functionality through the MCP protocol, allowing AI assistants to:
- Query device information and status
- List available commands
- Execute device commands
- Monitor device parameters in real-time

## Prerequisites

- Node.js 18+ 
- A running SiLA server with REST API endpoints
- npm or yarn

## Installation

1. Clone or download this project
2. Install dependencies:
```bash
npm install
```

3. Build the TypeScript code:
```bash
npm run build
```

## Configuration

The server reads configuration from environment variables:

- `SILA_SERVER_URL`: The URL of your SiLA server (default: `http://localhost:50051`)
- `SILA_SERVER_INSECURE`: Whether to allow insecure connections (default: `true`)

Example:
```bash
export SILA_SERVER_URL=http://192.168.1.100:50051
export SILA_SERVER_INSECURE=false
```

## Running the Server

### Development mode (with auto-rebuild):
```bash
npm run watch
```

### Production mode:
```bash
npm start
```

## MCP Capabilities

### Tools

- **get_device_info**: Retrieve device information including name, type, manufacturer, serial number, and firmware version
- **list_device_commands**: Get all available commands the device supports
- **execute_command**: Execute a command on the device with optional parameters
- **get_device_status**: Get real-time device status including operational state

### Resources

- **sila://device/info**: Device metadata and capabilities (read-only)
- **sila://device/status**: Current device status (read-only)

## Integration with Claude

To use this MCP server with Claude, add it to your MCP configuration:

```json
{
  "mcpServers": {
    "sila": {
      "command": "node",
      "args": ["path/to/build/index.js"],
      "env": {
        "SILA_SERVER_URL": "http://localhost:50051"
      }
    }
  }
}
```

## SiLA Server Requirements

Your SiLA server should provide the following REST API endpoints:

- `GET /health` - Health check endpoint
- `GET /device/info` - Device information
- `GET /device/status` - Device status
- `GET /device/commands` - List available commands
- `POST /device/commands/{commandName}` - Execute a command
- `GET /device/parameters/{parameterName}` - Get parameter value
- `PUT /device/parameters/{parameterName}` - Set parameter value

## Project Structure

```
.
├── src/
│   ├── index.ts           # Main MCP server implementation
│   └── sila-client.ts     # SiLA server client library
├── build/                 # Compiled JavaScript (generated)
├── package.json
├── tsconfig.json
└── README.md
```

## Development

### Build for production:
```bash
npm run build
```

### Watch mode (recommended for development):
```bash
npm run watch
```

## Troubleshooting

### Connection Issues
- Verify the SiLA server is running at the configured URL
- Check firewall rules allow communication
- Enable debug logging by setting `DEBUG=*`

### Missing Device Endpoints
- Ensure your SiLA server implements all required REST endpoints
- Check the endpoint paths match the expected format
- Review SiLA server documentation

## License

MIT