|
| 1 | +class McpToolbox < Formula |
| 2 | + desc "MCP server for databases" |
| 3 | + homepage "https://github.com/googleapis/genai-toolbox" |
| 4 | + url "https://github.com/googleapis/genai-toolbox/archive/refs/tags/v0.9.0.tar.gz" |
| 5 | + sha256 "a18dd9e173ac008f725d7111b8d70b2053dfe99049795d73a74f38ac18227b21" |
| 6 | + license "Apache-2.0" |
| 7 | + |
| 8 | + bottle do |
| 9 | + sha256 cellar: :any_skip_relocation, arm64_sequoia: "652d5e51a9f0b8691b7a7cd039f406bb7e5b9514253468bd3e6bfa7f47a0a7f8" |
| 10 | + sha256 cellar: :any_skip_relocation, arm64_sonoma: "652d5e51a9f0b8691b7a7cd039f406bb7e5b9514253468bd3e6bfa7f47a0a7f8" |
| 11 | + sha256 cellar: :any_skip_relocation, arm64_ventura: "652d5e51a9f0b8691b7a7cd039f406bb7e5b9514253468bd3e6bfa7f47a0a7f8" |
| 12 | + sha256 cellar: :any_skip_relocation, sonoma: "66e1b40e82706e8228b1ab4e7d39109555a2be276cb04abee04fe27599b908b3" |
| 13 | + sha256 cellar: :any_skip_relocation, ventura: "66e1b40e82706e8228b1ab4e7d39109555a2be276cb04abee04fe27599b908b3" |
| 14 | + sha256 cellar: :any_skip_relocation, x86_64_linux: "07d6df579fcb595e20cd7810f935d113690664c75854e346e74b73f9f2c0bd11" |
| 15 | + end |
| 16 | + |
| 17 | + depends_on "go" => :build |
| 18 | + |
| 19 | + def install |
| 20 | + ldflags = %W[ |
| 21 | + -s -w |
| 22 | + -X github.com/googleapis/genai-toolbox/cmd.buildType=#{tap.user} |
| 23 | + ] |
| 24 | + system "go", "build", *std_go_args(ldflags:, output: bin/"toolbox") |
| 25 | + end |
| 26 | + |
| 27 | + test do |
| 28 | + assert_match version.to_s, shell_output("#{bin}/toolbox --version") |
| 29 | + |
| 30 | + (testpath/"tools.yaml").write <<~EOS |
| 31 | + sources: |
| 32 | + my-sqlite-memory-db: |
| 33 | + kind: "sqlite" |
| 34 | + database: ":memory:" |
| 35 | + EOS |
| 36 | + |
| 37 | + port = free_port |
| 38 | + pid = fork { exec bin/"toolbox", "--tools-file", testpath/"tools.yaml", "--port", port.to_s } |
| 39 | + |
| 40 | + sleep 5 |
| 41 | + |
| 42 | + begin |
| 43 | + output = shell_output("curl -s -i http://localhost:#{port} 2>&1") |
| 44 | + assert_match "HTTP/1.1 200 OK", output, "Expected HTTP/1.1 200 OK response" |
| 45 | + ensure |
| 46 | + Process.kill("TERM", pid) |
| 47 | + Process.wait(pid) |
| 48 | + end |
| 49 | + end |
| 50 | +end |
0 commit comments