> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mcpfy.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# List MCP Servers

> Retrieve a list of all MCP servers for the authenticated user

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET https://api.mcpfy.ai/dev/v1/mcp-servers \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json"
  ```

  ```javascript Node.js - Fetch API theme={null}
  const listMCPServers = async () => {
    const response = await fetch('https://api.mcpfy.ai/dev/v1/mcp-servers', {
      method: 'GET',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
      }
    });

    const data = await response.json();
    return data;
  };

  // Usage
  listMCPServers()
    .then(result => console.log(result))
    .catch(error => console.error('Error:', error));
  ```

  ```javascript Node.js - Axios theme={null}
  const axios = require('axios');

  const listMCPServers = async () => {
    try {
      const response = await axios.get('https://api.mcpfy.ai/dev/v1/mcp-servers', {
        headers: {
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json'
        }
      });

      return response.data;
    } catch (error) {
      console.error('Error listing MCP servers:', error.response?.data || error.message);
      throw error;
    }
  };

  // Usage
  listMCPServers()
    .then(result => console.log('MCP Servers:', result))
    .catch(error => console.error('Failed to list servers'));
  ```

  ```python Python - Requests theme={null}
  import requests

  def list_mcp_servers():
      url = "https://api.mcpfy.ai/dev/v1/mcp-servers"
      
      headers = {
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json'
      }
      
      try:
          response = requests.get(url, headers=headers, timeout=30)
          response.raise_for_status()
          return response.json()
      except requests.exceptions.RequestException as e:
          print(f"Error listing MCP servers: {e}")
          raise

  # Usage
  try:
      result = list_mcp_servers()
      print("MCP Servers:", result)
  except Exception as error:
      print(f"Failed to list servers: {error}")
  ```

  ```python Python - HTTPX (Async) theme={null}
  import httpx
  import asyncio

  async def list_mcp_servers():
      url = "https://api.mcpfy.ai/dev/v1/mcp-servers"
      
      headers = {
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json'
      }
      
      async with httpx.AsyncClient() as client:
          try:
              response = await client.get(url, headers=headers, timeout=30)
              response.raise_for_status()
              return response.json()
          except httpx.RequestError as e:
              print(f"Error listing MCP servers: {e}")
              raise

  # Usage
  async def main():
      try:
          result = await list_mcp_servers()
          print("MCP Servers:", result)
      except Exception as error:
          print(f"Failed to list servers: {error}")

  # Run the async function
  asyncio.run(main())
  ```

  ```php PHP - cURL theme={null}
  <?php
  function listMCPServers() {
      $url = 'https://api.mcpfy.ai/dev/v1/mcp-servers';
      
      $headers = [
          'Authorization: Bearer YOUR_API_KEY',
          'Content-Type: application/json'
      ];
      
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_TIMEOUT, 30);
      
      $response = curl_exec($ch);
      $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
      
      if (curl_errno($ch)) {
          $error = curl_error($ch);
          curl_close($ch);
          throw new Exception("cURL error: " . $error);
      }
      
      curl_close($ch);
      
      if ($httpCode !== 200) {
          throw new Exception("HTTP error: " . $httpCode);
      }
      
      return json_decode($response, true);
  }

  // Usage
  try {
      $result = listMCPServers();
      echo "MCP Servers: " . json_encode($result, JSON_PRETTY_PRINT) . "\n";
  } catch (Exception $e) {
      echo "Failed to list servers: " . $e->getMessage() . "\n";
  }
  ?>
  ```

  ```go Go theme={null}
  package main

  import (
      "encoding/json"
      "fmt"
      "io"
      "net/http"
      "time"
  )

  type MCPServer struct {
      ID          string    `json:"id"`
      Name        string    `json:"name"`
      URL         string    `json:"url"`
      Status      string    `json:"status"`
      CreatedAt   time.Time `json:"created_at"`
      UpdatedAt   time.Time `json:"updated_at"`
  }

  type MCPServersResponse struct {
      Status string      `json:"status"`
      Data   []MCPServer `json:"data"`
      Error  *struct {
          Code    string `json:"code"`
          Message string `json:"message"`
      } `json:"error,omitempty"`
  }

  func listMCPServers() (*MCPServersResponse, error) {
      url := "https://api.mcpfy.ai/dev/v1/mcp-servers"
      
      req, err := http.NewRequest("GET", url, nil)
      if err != nil {
          return nil, fmt.Errorf("failed to create request: %w", err)
      }
      
      req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
      req.Header.Set("Content-Type", "application/json")
      
      client := &http.Client{Timeout: 30 * time.Second}
      resp, err := client.Do(req)
      if err != nil {
          return nil, fmt.Errorf("failed to make request: %w", err)
      }
      defer resp.Body.Close()
      
      body, err := io.ReadAll(resp.Body)
      if err != nil {
          return nil, fmt.Errorf("failed to read response: %w", err)
      }
      
      var result MCPServersResponse
      if err := json.Unmarshal(body, &result); err != nil {
          return nil, fmt.Errorf("failed to unmarshal response: %w", err)
      }
      
      return &result, nil
  }

  func main() {
      result, err := listMCPServers()
      if err != nil {
          fmt.Printf("Failed to list servers: %v\n", err)
          return
      }
      
      fmt.Printf("MCP Servers: %+v\n", result)
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  [
    {
      "id": "64f8a1b2c3d4e5f6a7b8c9d0",
      "name": "My MCP Server",
      "isActive": true,
      "createdAt": "2023-09-06T10:30:00.000Z",
      "updatedAt": "2023-09-06T10:30:00.000Z"
    }
  ]
  ```
</ResponseExample>


## OpenAPI

````yaml GET /mcp-servers
openapi: 3.1.0
info:
  title: MCPfy API
  description: MCPfy API for generating MCP tokens and managing plant store operations
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.mcpfy.ai/dev/v1
security:
  - bearerAuth: []
paths:
  /mcp-servers:
    get:
      tags:
        - MCP Servers
      summary: List MCP Servers
      description: Retrieve a list of all MCP servers for the authenticated user
      operationId: listMCPServers
      responses:
        '200':
          description: Successfully retrieved MCP servers
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/MCPServer'
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDetails'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDetails'
      security:
        - bearerAuth: []
components:
  schemas:
    MCPServer:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the MCP server
          example: 64f8a1b2c3d4e5f6a7b8c9d0
        name:
          type: string
          description: Name of the MCP server
          example: My MCP Server
        isActive:
          type: boolean
          description: Whether the MCP server is currently active
          example: true
        createdAt:
          type: string
          format: date-time
          description: Timestamp when the server was created
          example: '2023-09-06T10:30:00.000Z'
        updatedAt:
          type: string
          format: date-time
          description: Timestamp when the server was last updated
          example: '2023-09-06T10:30:00.000Z'
      required:
        - id
        - name
        - isActive
        - createdAt
        - updatedAt
    ErrorDetails:
      type: object
      properties:
        code:
          description: Error code identifying the type of error
          type: string
          example: invalid_server_id
        message:
          description: Human-readable error message describing the issue
          type: string
          example: The provided MCP server ID is invalid or not found
        retryAfter:
          description: Seconds to wait before retrying (only for rate limit errors)
          type: integer
          example: 45
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````