Commit 0ffde0d
cmd/bash/main.go
@@ -1,69 +1,22 @@
package main
import (
- "context"
- "flag"
- "fmt"
- "log"
+ "context"
+ "flag"
+ "log"
- "github.com/xlgmokha/mcp/pkg/bash"
+ "github.com/xlgmokha/mcp/pkg/bash"
)
-func printHelp() {
- fmt.Printf(`Bash MCP Server
-
-DESCRIPTION:
- A Model Context Protocol server that provides shell command execution capabilities.
- Enables direct execution of bash commands with streaming output.
-
-USAGE:
- mcp-bash [directory]
-
-ARGUMENTS:
- directory Working directory for command execution (default: current directory)
-
-OPTIONS:
- --help Show this help message
-
-EXAMPLE USAGE:
- # Use current directory
- mcp-bash
-
- # Use specific directory
- mcp-bash /path/to/project
-
- # Execute a command
- echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "exec", "arguments": {"command": "ls -la"}}}' | mcp-bash
-
-MCP CAPABILITIES:
- - Tools: exec (execute shell commands with streaming output)
- - Resources: bash builtins and coreutils discovery
- - Protocol: JSON-RPC 2.0 over stdio
-
-For detailed documentation, see: cmd/bash/README.md
-`)
-}
-
func main() {
- var help = flag.Bool("help", false, "Show help message")
- flag.Parse()
-
- if *help {
- printHelp()
- return
- }
-
- var workingDir string
- if len(flag.Args()) > 0 {
- workingDir = flag.Arg(0)
- } else {
- workingDir = "."
- }
-
- server := bash.New(workingDir)
-
- ctx := context.Background()
- if err := server.Run(ctx); err != nil {
- log.Fatalf("Server error: %v", err)
- }
-}
\ No newline at end of file
+ var workingDir string
+ if len(flag.Args()) > 0 {
+ workingDir = flag.Arg(0)
+ } else {
+ workingDir = "."
+ }
+
+ if err := bash.New(workingDir).Run(context.Background()); err != nil {
+ log.Fatalf("Server error: %v", err)
+ }
+}
cmd/fetch/main.go
@@ -2,57 +2,13 @@ package main
import (
"context"
- "flag"
- "fmt"
"log"
"github.com/xlgmokha/mcp/pkg/fetch"
)
-func printHelp() {
- fmt.Printf(`Fetch MCP Server
-
-DESCRIPTION:
- A Model Context Protocol server that provides web content fetching capabilities.
- Features advanced HTML processing, markdown conversion, and content extraction.
-
-USAGE:
- mcp-fetch [options]
-
-OPTIONS:
- --help Show this help message
-
-EXAMPLE USAGE:
- # Start the fetch server
- mcp-fetch
-
- # Test with MCP protocol
- echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "fetch", "arguments": {"url": "https://example.com"}}}' | mcp-fetch
-
-MCP CAPABILITIES:
- - Tools: fetch (web content retrieval with HTML processing)
- - Features: goquery HTML parsing, html-to-markdown conversion
- - Content filtering: Automatic removal of ads, navigation, scripts
- - Protocol: JSON-RPC 2.0 over stdio
-
-For detailed documentation, see: cmd/fetch/README.md
-`)
-}
-
func main() {
- // Parse command line flags
- var help = flag.Bool("help", false, "Show help message")
- flag.Parse()
-
- if *help {
- printHelp()
- return
- }
-
- server := fetch.New()
-
- ctx := context.Background()
- if err := server.Run(ctx); err != nil {
+ if err := fetch.New().Run(context.Background()); err != nil {
log.Fatalf("Server error: %v", err)
}
}
cmd/filesystem/main.go
@@ -3,64 +3,21 @@ package main
import (
"context"
"flag"
- "fmt"
"log"
+ "strings"
"github.com/xlgmokha/mcp/pkg/filesystem"
)
-func printHelp() {
- fmt.Printf(`Filesystem MCP Server - Ultra-Minimal Edition
-
-DESCRIPTION:
- A ultra-minimal Model Context Protocol server optimized for efficient filesystem access
- with open models like gpt-oss:latest. Provides essential file operations with minimal
- token overhead.
-
-USAGE:
- mcp-filesystem [directory]
-
-ARGUMENTS:
- directory Directory to allow access to (default: current directory)
-
-OPTIONS:
- --help Show this help message
-
-EXAMPLE USAGE:
- # Use current directory
- mcp-filesystem
-
- # Allow access to specific directory
- mcp-filesystem /tmp
-
- # Test with MCP protocol
- echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | mcp-filesystem /tmp
-
- # Create and read a file
- echo '{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "write_file", "arguments": {"path": "/tmp/test.txt", "content": "Hello!"}}}' | mcp-filesystem /tmp
-`)
-}
-
func main() {
- var help = flag.Bool("help", false, "Show help message")
- flag.Parse()
-
- if *help {
- printHelp()
- return
- }
-
- var directory string
- if len(flag.Args()) > 0 {
- directory = flag.Arg(0)
- } else {
- directory = "."
- }
-
- server := filesystem.New([]string{directory})
-
- ctx := context.Background()
- if err := server.Run(ctx); err != nil {
- log.Fatalf("Server error: %v", err)
- }
+ dirs := []string{}
+ if len(flag.Args()) > 0 {
+ dirs = append(dirs, strings.Split(flag.Arg(0), ",")...)
+ } else {
+ dirs = append(dirs, ".")
+ }
+
+ if err := filesystem.New(dirs).Run(context.Background()); err != nil {
+ log.Fatalf("Server error: %v", err)
+ }
}
cmd/git/main.go
@@ -3,72 +3,25 @@ package main
import (
"context"
"flag"
- "fmt"
"log"
"os"
"github.com/xlgmokha/mcp/pkg/git"
)
-func printHelp() {
- fmt.Printf(`Git MCP Server
-
-DESCRIPTION:
- A Model Context Protocol server that provides Git repository operations and browsing.
- Supports Git commands, file browsing, branch management, and repository exploration.
-
-USAGE:
- mcp-git [directory]
-
-ARGUMENTS:
- directory Path to the Git repository (default: current directory)
-
-OPTIONS:
- --help Show this help message
-
-EXAMPLE USAGE:
- # Start server for current directory
- mcp-git
-
- # Start server for specific repository
- mcp-git /path/to/repo
-
- # Test with MCP protocol
- echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": {"name": "test", "version": "1.0.0"}}}' | mcp-git
-
-MCP CAPABILITIES:
- - Tools: git_status, git_diff, git_commit, git_add, git_log, git_create_branch, git_checkout, and more
- - Resources: git:// URIs for files, branches, and commits
- - Protocol: JSON-RPC 2.0 over stdio
-
-For detailed documentation, see: cmd/git/README.md
-`)
-}
-
func main() {
- var help = flag.Bool("help", false, "Show help message")
- flag.Parse()
-
- if *help {
- printHelp()
- return
- }
-
- var repoPath string
- if len(flag.Args()) > 0 {
- repoPath = flag.Arg(0)
- } else {
- var err error
- repoPath, err = os.Getwd()
- if err != nil {
- log.Fatalf("Failed to get current directory: %v", err)
- }
- }
-
- server := git.New(repoPath)
-
- ctx := context.Background()
- if err := server.Run(ctx); err != nil {
- log.Fatalf("Server error: %v", err)
- }
+ var repoPath string
+ if len(flag.Args()) > 0 {
+ repoPath = flag.Arg(0)
+ } else {
+ var err error
+ repoPath, err = os.Getwd()
+ if err != nil {
+ log.Fatalf("Failed to get current directory: %v", err)
+ }
+ }
+
+ if err := git.New(repoPath).Run(context.Background()); err != nil {
+ log.Fatalf("Server error: %v", err)
+ }
}