Commit a3a19f8

mo khan <mo@mokhan.ca>
2025-08-18 20:24:40
refactor: default to the current working directory
1 parent 817bb38
Changed files (4)
cmd/filesystem/main.go
@@ -5,13 +5,12 @@ import (
 	"flag"
 	"fmt"
 	"log"
-	"strings"
 
 	"github.com/xlgmokha/mcp/pkg/filesystem"
 )
 
 func printHelp() {
-	fmt.Printf(`Filesystem MCP Server - Ultra-Minimal Edition
+  fmt.Printf(`Filesystem MCP Server - Ultra-Minimal Edition
 
 DESCRIPTION:
     A ultra-minimal Model Context Protocol server optimized for efficient filesystem access
@@ -19,52 +18,49 @@ DESCRIPTION:
     token overhead.
 
 USAGE:
-    mcp-filesystem [options]
+    mcp-filesystem [directory]
+
+ARGUMENTS:
+    directory    Directory to allow access to (default: current directory)
 
 OPTIONS:
-    --allowed-directory <paths>    Comma-separated list of allowed directories
-    --help                        Show this help message
+    --help       Show this help message
 
 EXAMPLE USAGE:
-    # Allow access to single directory
-    mcp-filesystem --allowed-directory /tmp
+    # Use current directory
+    mcp-filesystem
 
-    # Allow access to multiple directories  
-    mcp-filesystem --allowed-directory /tmp,/home/user/projects
+    # Allow access to specific directory
+    mcp-filesystem /tmp
 
     # Test with MCP protocol
-    echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | mcp-filesystem --allowed-directory /tmp
+    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 --allowed-directory /tmp
+    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() {
-	// Parse command line flags
-	var allowedDirectoriesFlag = flag.String("allowed-directory", "", "Comma-separated list of allowed directories")
-	var help = flag.Bool("help", false, "Show help message")
-	flag.Parse()
-
-	if *help {
-		printHelp()
-		return
-	}
-
-	var allowedDirs []string
-	if *allowedDirectoriesFlag != "" {
-		allowedDirs = strings.Split(*allowedDirectoriesFlag, ",")
-	} else if len(flag.Args()) > 0 {
-		// Fall back to positional arguments for backward compatibility
-		allowedDirs = flag.Args()
-	} else {
-		log.Fatal("Usage: mcp-filesystem --allowed-directory <dir1,dir2,...> OR mcp-filesystem <dir1> [dir2...]")
-	}
-
-	server := filesystem.New(allowedDirs)
-
-	ctx := context.Background()
-	if err := server.Run(ctx); err != nil {
-		log.Fatalf("Server error: %v", err)
-	}
+  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)
+  }
 }
cmd/git/main.go
@@ -11,39 +11,31 @@ import (
 )
 
 func printHelp() {
-	fmt.Printf(`Git MCP Server
+  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 [options]
+    mcp-git [directory]
+
+ARGUMENTS:
+    directory    Path to the Git repository (default: current directory)
 
 OPTIONS:
-    --repository <path>    Path to the Git repository (default: current directory)
-    --help                Show this help message
+    --help       Show this help message
 
 EXAMPLE USAGE:
     # Start server for current directory
     mcp-git
 
     # Start server for specific repository
-    mcp-git --repository /path/to/repo
+    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
 
-ADDING TO CLAUDE CODE:
-    # Add to Claude Code for current directory
-    claude mcp add mcp-git -- /usr/local/bin/mcp-git --repository $(pwd)
-
-    # Add to Claude Code for specific repository
-    claude mcp add mcp-git -- /usr/local/bin/mcp-git --repository /path/to/repo
-
-    # Add to Claude Code (minimal, uses current directory)
-    claude mcp add mcp-git -- /usr/local/bin/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
@@ -54,28 +46,29 @@ For detailed documentation, see: cmd/git/README.md
 }
 
 func main() {
-	var repository = flag.String("repository", "", "Path to the git repository (defaults to current directory)")
-	var help = flag.Bool("help", false, "Show help message")
-	flag.Parse()
-
-	if *help {
-		printHelp()
-		return
-	}
-
-	repoPath := *repository
-	if repoPath == "" {
-		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 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)
+  }
 }
cmd/maildir/main.go
@@ -5,44 +5,35 @@ import (
 	"flag"
 	"fmt"
 	"log"
-	"strings"
 
 	"github.com/xlgmokha/mcp/pkg/maildir"
 )
 
 func printHelp() {
-	fmt.Printf(`Maildir MCP Server
+  fmt.Printf(`Maildir MCP Server
 
 DESCRIPTION:
     A Model Context Protocol server that provides secure email management through Maildir format.
     Enables comprehensive email analysis, searching, and contact management capabilities.
 
 USAGE:
-    mcp-maildir [options]
+    mcp-maildir [directory]
+
+ARGUMENTS:
+    directory    Path to the Maildir directory (default: current directory)
 
 OPTIONS:
-    --maildir-path <paths>    Comma-separated list of Maildir directory paths (required)
-    --help                   Show this help message
+    --help       Show this help message
 
 EXAMPLE USAGE:
-    # Single mailbox
-    mcp-maildir --maildir-path ~/.local/share/mail
+    # Use current directory
+    mcp-maildir
 
-    # Multiple mailboxes
-    mcp-maildir --maildir-path ~/.local/share/mail/personal,~/.local/share/mail/work
+    # Single mailbox
+    mcp-maildir ~/.local/share/mail
 
     # Test with MCP protocol
-    echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "maildir_scan_folders", "arguments": {"maildir_path": "~/.local/share/mail"}}}' | mcp-maildir --maildir-path ~/.local/share/mail
-
-ADDING TO CLAUDE CODE:
-    # Add to Claude Code for single mailbox
-    claude mcp add mcp-maildir -- /usr/local/bin/mcp-maildir --maildir-path ~/.local/share/mail
-
-    # Add to Claude Code for multiple mailboxes
-    claude mcp add mcp-maildir -- /usr/local/bin/mcp-maildir --maildir-path ~/.local/share/mail/personal,~/.local/share/mail/work
-
-    # Add to Claude Code for standard mail directory
-    claude mcp add mcp-maildir -- /usr/local/bin/mcp-maildir --maildir-path ~/.local/share/mail/personal
+    echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "maildir_scan_folders", "arguments": {"maildir_path": "~/.local/share/mail"}}}' | mcp-maildir ~/.local/share/mail
 
 MCP CAPABILITIES:
     - Tools: maildir_scan_folders, maildir_list_messages, maildir_read_message, maildir_search_messages, maildir_get_thread, maildir_analyze_contacts, maildir_get_statistics
@@ -56,30 +47,25 @@ For detailed documentation, see: cmd/maildir/README.md
 }
 
 func main() {
-	// Parse command line flags
-	var maildirPathsFlag = flag.String("maildir-path", "", "Comma-separated list of allowed maildir paths")
-	var help = flag.Bool("help", false, "Show help message")
-	flag.Parse()
-
-	if *help {
-		printHelp()
-		return
-	}
-
-	var maildirPaths []string
-	if *maildirPathsFlag != "" {
-		maildirPaths = strings.Split(*maildirPathsFlag, ",")
-	} else if len(flag.Args()) > 0 {
-		// Fall back to positional arguments for backward compatibility
-		maildirPaths = flag.Args()
-	} else {
-		log.Fatal("Usage: mcp-maildir --maildir-path <path1,path2,...> OR mcp-maildir <path1> [path2...]")
-	}
-
-	server := maildir.New(maildirPaths)
-
-	ctx := context.Background()
-	if err := server.Run(ctx); err != nil {
-		log.Fatalf("Server error: %v", err)
-	}
+  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 := maildir.New([]string{directory})
+
+  ctx := context.Background()
+  if err := server.Run(ctx); err != nil {
+    log.Fatalf("Server error: %v", err)
+  }
 }
\ No newline at end of file
Makefile
@@ -34,10 +34,15 @@ test: ## Run all tests
 	$(GOTEST) -v ./...
 
 test-smoke: clean build
-	echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}}' | ./bin/mcp-filesystem --allowed-directory . | jq '.'
-	echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | ./bin/mcp-filesystem --allowed-directory . | jq '.'
-	echo '{"jsonrpc": "2.0", "id": 1, "method": "resources/list", "params": {}}' | ./bin/mcp-filesystem --allowed-directory . | jq '.'
-	echo '{"jsonrpc": "2.0", "id": 1, "method": "prompts/list", "params": {}}' | ./bin/mcp-filesystem --allowed-directory . | jq '.'
+	@echo "Running smoke tests for all MCP servers..."
+	@for server in $(SERVERS); do \
+		echo "Testing mcp-$$server..."; \
+		echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}}' | ./bin/mcp-$$server . | jq '.'; \
+		echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | ./bin/mcp-$$server . | jq '.'; \
+		echo '{"jsonrpc": "2.0", "id": 1, "method": "resources/list", "params": {}}' | ./bin/mcp-$$server . | jq '.'; \
+		echo '{"jsonrpc": "2.0", "id": 1, "method": "prompts/list", "params": {}}' | ./bin/mcp-$$server . | jq '.'; \
+		echo '{"jsonrpc": "2.0", "id": 1, "method": "roots/list", "params": {}}' | ./bin/mcp-$$server . | jq '.'; \
+	done
 
 test-coverage: ## Run tests with coverage
 	$(GOTEST) -cover ./...