Initial minimal mcp server for KorAP
diff --git a/cmd/korap-mcp/main.go b/cmd/korap-mcp/main.go
new file mode 100644
index 0000000..0cf7fb3
--- /dev/null
+++ b/cmd/korap-mcp/main.go
@@ -0,0 +1,91 @@
+package main
+
+import (
+ "context"
+ "fmt"
+ "os"
+
+ "github.com/korap/korap-mcp/mcp"
+ mcplib "github.com/mark3labs/mcp-go/mcp"
+)
+
+// Run is the default command that starts the MCP server
+func (c *CLI) Run() error {
+ // Handle version flag
+ if c.Version {
+ fmt.Printf("%s version %s\n", c.GetServerName(), c.GetServerVersion())
+ os.Exit(0)
+ }
+
+ // Validate configuration and setup logging
+ logger, err := c.ValidateAndSetupLogging()
+ if err != nil {
+ return err
+ }
+
+ logger.Info().
+ Str("version", c.GetServerVersion()).
+ Str("korap_url", c.KorAP.BaseURL).
+ Bool("oauth_enabled", c.OAuth.Enabled).
+ Msg("KorAP MCP Server starting...")
+
+ // Create MCP server
+ server := mcp.NewServer(c.GetServerName(), c.GetServerVersion())
+
+ // Add a simple ping tool for testing
+ err = server.AddTool(
+ "ping",
+ "Simple ping tool to test server connectivity",
+ map[string]interface{}{
+ "type": "object",
+ "properties": map[string]interface{}{
+ "message": map[string]interface{}{
+ "type": "string",
+ "description": "Message to echo back",
+ },
+ },
+ },
+ func(ctx context.Context, request mcplib.CallToolRequest) (*mcplib.CallToolResult, error) {
+ message, err := request.RequireString("message")
+ if err != nil {
+ message = "pong"
+ }
+ logger.Debug().
+ Str("message", message).
+ Msg("Ping tool called")
+ return mcplib.NewToolResultText(fmt.Sprintf("KorAP Server response: %s", message)), nil
+ },
+ )
+
+ if err != nil {
+ return fmt.Errorf("failed to add ping tool: %w", err)
+ }
+
+ logger.Info().Msg("Server ready - serving MCP via stdio")
+
+ // Start the MCP server
+ if err := server.Serve(); err != nil {
+ return fmt.Errorf("server error: %w", err)
+ }
+
+ return nil
+}
+
+func main() {
+ // Setup CLI and parser
+ cli, parser, err := SetupCLI()
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Failed to setup CLI: %v\n", err)
+ os.Exit(1)
+ }
+
+ // Parse command line arguments and run
+ ctx, err := parser.Parse(os.Args[1:])
+ if err != nil {
+ parser.FatalIfErrorf(err)
+ }
+
+ // Run the appropriate command (default or subcommand)
+ err = ctx.Run(cli)
+ ctx.FatalIfErrorf(err)
+}