Skip to content
Draft
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
149 changes: 148 additions & 1 deletion docs/yml-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,51 @@ properties:
description: "Tool-specific environment variables"
additionalProperties:
type: string
name:
type: string
description: "Custom tool name (defaults to function name)"
version:
type: string
description: "Tool version"
author:
type: string
description: "Tool author"
tags:
type: array
description: "Tool tags for categorization"
items:
type: string
category:
type: string
description: "Tool category"
timeout:
type: integer
description: "Tool timeout in seconds (default: 300)"
retries:
type: integer
description: "Number of retries on failure (default: 0)"
examples:
type: array
description: "Usage examples"
items:
type: object
properties:
description:
type: string
description: "Example description"
command:
type: string
description: "Example command"
dependencies:
type: array
description: "Required system dependencies"
items:
type: string
permissions:
type: array
description: "Required permissions"
items:
type: string

resources:
type: object
Expand Down Expand Up @@ -640,6 +685,102 @@ prompts:
default: ""
```

## Enhanced Tool Features

### Tool Metadata and Organization

```yaml
tools:
DatabaseBackup:
name: "db-backup" # Custom tool name
version: "2.1.0"
author: "DevOps Team"
category: "database"
tags: ["backup", "database", "maintenance"]
cmd: "mysqldump {{ database }} > {{ backup_file }}"
desc: "Create a database backup"
timeout: 600 # 10 minutes
retries: 2
dependencies: ["mysqldump", "mysql"]
permissions: ["database:read", "file:write"]
examples:
- description: "Backup production database"
command: "db-backup --database=prod_db --backup_file=prod_backup.sql"
- description: "Backup with timestamp"
command: "db-backup --database=test_db --backup_file=test_$(date +%Y%m%d).sql"
args:
- name: database
help: "Database name to backup"
type: string
- name: backup_file
help: "Output backup file path"
type: string
default: "backup.sql"
```

### Advanced Tool Configuration

```yaml
tools:
SystemMonitor:
name: "system-monitor"
version: "1.0.0"
author: "System Admin"
category: "monitoring"
tags: ["system", "monitoring", "health"]
cmd: |
{% if metric == "cpu" %}
top -bn1 | grep "Cpu(s)" | awk '{print $2}' | cut -d'%' -f1
{% elif metric == "memory" %}
free | grep Mem | awk '{printf "%.2f", $3/$2 * 100.0}'
{% elif metric == "disk" %}
df -h {{ path or "/" }} | awk 'NR==2{print $5}' | cut -d'%' -f1
{% endif %}
desc: "Monitor system metrics (CPU, memory, disk usage)"
timeout: 30
retries: 1
dependencies: ["top", "free", "df"]
examples:
- description: "Check CPU usage"
command: "system-monitor --metric=cpu"
- description: "Check memory usage"
command: "system-monitor --metric=memory"
- description: "Check disk usage for specific path"
command: "system-monitor --metric=disk --path=/var"
args:
- name: metric
help: "Metric to monitor"
type: string
choices: ["cpu", "memory", "disk"]
- name: path
help: "Path for disk usage check"
type: string
default: "/"
```

### Tool with Custom Name and Tags

```yaml
tools:
FileSearch:
name: "find-files" # Custom name different from function name
tags: ["file", "search", "utility"]
cmd: "find {{ path }} -name '{{ pattern }}' -type f"
desc: "Search for files matching a pattern"
examples:
- description: "Find Python files"
command: "find-files --path=/home/user --pattern='*.py'"
args:
- name: path
help: "Directory to search"
type: string
default: "."
- name: pattern
help: "File pattern to match"
type: string
default: "*"
```

## Best Practices

1. **Use descriptive names**: Choose clear, meaningful names for tools, resources, prompts, and arguments
Expand All @@ -650,4 +791,10 @@ prompts:
6. **Test templates**: Validate Jinja2 templates before deployment
7. **Resource URIs**: Use meaningful URIs for resources (e.g., `system://info`, `file://config`)
8. **Prompt clarity**: Make prompts clear and specific with good structure
9. **MIME types**: Specify appropriate MIME types for resources when possible
9. **MIME types**: Specify appropriate MIME types for resources when possible
10. **Use metadata**: Leverage version, author, category, and tags for better organization
11. **Set timeouts**: Configure appropriate timeouts for long-running operations
12. **Handle retries**: Use retries for operations that might fail due to temporary issues
13. **Document dependencies**: List all required system dependencies
14. **Provide examples**: Include usage examples to help users understand tool functionality
15. **Specify permissions**: Document required permissions for security and access control
123 changes: 123 additions & 0 deletions enhanced_server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# enhanced-mcp-server

Enhanced MCP server demonstrating new features

## Installation

### Option 1: Using Virtual Environment (Recommended)

1. **Create a virtual environment**:
```bash
python3 -m venv venv
```


2. **Activate the virtual environment**:
```bash
source venv/bin/activate
```

3. **Install dependencies**:
```bash
pip install -r requirements.txt
```

4. **Run the server**:
```bash
python enhanced_mcp_server_server.py
```

5. **Deactivate when done** (optional):
```bash
deactivate
```

### Option 2: System-wide Installation

1. **Install dependencies**:
```bash
pip install -r requirements.txt
```

2. **Run the server**:
```bash
python enhanced_mcp_server_server.py
```


## Tools


### DatabaseBackup

Create a database backup with compression and validation

**Function**: `databasebackup`

**Arguments**:
- `database` (string): Database name- `backup_file` (string): Path to a file or directory
**Command**: `mysqldump {{ database }} > {{ backup_file }}`


### SystemMonitor

Monitor system metrics (CPU, memory, disk usage)

**Function**: `systemmonitor`

**Arguments**:
- `metric` (string): Metric to monitor [choices: ['cpu', 'memory', 'disk']]- `path` (string): Path for disk usage check [default: /]
**Command**: `{% if metric == "cpu" %}
top -bn1 | grep "Cpu(s)" | awk '{print $2}' | cut -d'%' -f1
{% elif metric == "memory" %}
free | grep Mem | awk '{printf "%.2f", $3/$2 * 100.0}'
{% elif metric == "disk" %}
df -h {{ path or "/" }} | awk 'NR==2{print $5}' | cut -d'%' -f1
{% endif %}
`


### FileSearch

Search for files matching a pattern with optional size filtering

**Function**: `filesearch`

**Arguments**:
- `path` (string): Path to a file or directory- `pattern` (string): File pattern to match [default: *]- `size` (string): File size filter (e.g., +100M, -1G)
**Command**: `find {{ path }} -name '{{ pattern }}' -type f {% if size %} -size {{ size }}{% endif %}`


### LogAnalyzer

Analyze log files with various output formats and filtering

**Function**: `loganalyzer`

**Arguments**:
- `log_file` (string): Path to a file or directory- `format` (string): Output format [default: raw] [choices: ['text', 'json', 'raw']]- `lines` (number): Number of lines to show [default: 100]- `pattern` (string): Search pattern for text format- `filter` (string): JQ filter for JSON format
**Command**: `{% if format == "json" %}
jq '{{ filter }}' {{ log_file }}
{% elif format == "text" %}
grep "{{ pattern }}" {{ log_file }} | tail -{{ lines or 100 }}
{% else %}
tail -{{ lines or 100 }} {{ log_file }}
{% endif %}
`


## Configuration

This server was generated from a YAML configuration file. The server exposes shell commands as MCP tools with the following features:

- Jinja2 template support for dynamic command generation
- Argument validation with patterns and choices
- Environment variable support
- Error handling and timeout protection

## Server Information

- **Name**: enhanced-mcp-server
- **Version**: 2.0.0
- **Description**: Enhanced MCP server demonstrating new features
- **Tools**: 4
Loading