Skip to main content
Glama

MCPJungle mcp gateway

by mcpjungle
Mozilla Public License 2.0
638
  • Apple
mcp_clients.go•2.2 kB
package client import ( "bytes" "encoding/json" "fmt" "net/http" "github.com/mcpjungle/mcpjungle/pkg/types" ) func (c *Client) ListMcpClients() ([]types.McpClient, error) { u, _ := c.constructAPIEndpoint("/clients") req, err := c.newRequest(http.MethodGet, u, nil) if err != nil { return nil, fmt.Errorf("failed to create request: %w", err) } resp, err := c.httpClient.Do(req) if err != nil { return nil, fmt.Errorf("failed to send request to %s: %w", u, err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return nil, c.parseErrorResponse(resp) } var clients []types.McpClient if err := json.NewDecoder(resp.Body).Decode(&clients); err != nil { return nil, fmt.Errorf("failed to decode response: %w", err) } return clients, nil } func (c *Client) DeleteMcpClient(name string) error { u, _ := c.constructAPIEndpoint("/clients/" + name) req, err := c.newRequest(http.MethodDelete, u, nil) if err != nil { return fmt.Errorf("failed to create request: %w", err) } resp, err := c.httpClient.Do(req) if err != nil { return fmt.Errorf("failed to send request to %s: %w", u, err) } defer resp.Body.Close() if resp.StatusCode != http.StatusNoContent { return c.parseErrorResponse(resp) } return nil } func (c *Client) CreateMcpClient(mcpClient *types.McpClient) (string, error) { u, _ := c.constructAPIEndpoint("/clients") body, err := json.Marshal(mcpClient) if err != nil { return "", fmt.Errorf("failed to marshal client data: %w", err) } req, err := c.newRequest(http.MethodPost, u, bytes.NewReader(body)) if err != nil { return "", fmt.Errorf("failed to create request: %w", err) } req.Header.Set("Content-Type", "application/json") resp, err := c.httpClient.Do(req) if err != nil { return "", fmt.Errorf("failed to send request to %s: %w", u, err) } defer resp.Body.Close() if resp.StatusCode != http.StatusCreated { return "", c.parseErrorResponse(resp) } var response struct { AccessToken string `json:"access_token"` } if err := json.NewDecoder(resp.Body).Decode(&response); err != nil { return "", fmt.Errorf("failed to decode response: %w", err) } return response.AccessToken, nil }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mcpjungle/MCPJungle'

If you have feedback or need assistance with the MCP directory API, please join our Discord server