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

# Create Resource

> Create a new resource within a server.

## Path Parameters

<ParamField path="server_id" type="string" required>
  The numeric ID of the server to add the resource to.
</ParamField>

## Body Parameters

<ParamField body="uri" type="string" required>
  Unique URI identifier for this resource. Any scheme is valid — common patterns:
  `docs://getting-started`, `config://app`, `file:///data/report.json`.
</ParamField>

<ParamField body="name" type="string" required>
  Human-readable resource name shown to AI clients.
</ParamField>

<ParamField body="description" type="string">
  Description of what the resource contains. Shown to AI clients to help them decide when to read it.
</ParamField>

<ParamField body="mime_type" type="string" default="text/plain">
  MIME type of the returned content. Common values: `text/plain`, `text/markdown`, `application/json`.
</ParamField>

<ParamField body="data_source_type" type="string" default="static">
  Where the resource content comes from. One of:

  | Value      | Description                                             |
  | ---------- | ------------------------------------------------------- |
  | `static`   | Content stored directly in `data_source_config.content` |
  | `url`      | Content fetched from an external URL at read time       |
  | `wp_query` | Content generated from a WordPress query                |
  | `callback` | Content generated by a custom PHP callback function     |
</ParamField>

<ParamField body="data_source_config" type="object">
  Configuration for the chosen data source type. Send as a JSON object — the API encodes and stores it internally.

  **`static`** — serve fixed text content:

  ```json theme={null}
  { "content": "Your static text or markdown here." }
  ```

  **`url`** — fetch content from a remote URL:

  ```json theme={null}
  { "url": "https://api.example.com/data.json", "cache_ttl": 300 }
  ```

  `cache_ttl` is optional (seconds, default 0 = no cache).

  **`wp_query`** — query WordPress posts/pages:

  ```json theme={null}
  { "post_type": "post", "posts_per_page": 10, "orderby": "date", "order": "DESC" }
  ```

  Accepts any standard [WP\_Query argument](https://developer.wordpress.org/reference/classes/wp_query/).

  **`callback`** — call a registered PHP function:

  ```json theme={null}
  { "callback": "my_plugin_resource_callback" }
  ```

  The function receives `($resource, $params)` and must return a string.
</ParamField>

<ParamField body="template_uri" type="string">
  URI template (RFC 6570) for parameterized resources, e.g. `file:///data/{id}.json`.
  When set, the resource appears under `resources/templates/list` in the MCP protocol.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
       --url https://yoursite.com/wp-json/getmcp/v1/servers/1/resources \
       --header 'Authorization: Bearer gmcp_your_api_key' \
       --header 'content-type: application/json' \
       --data '
  {
    "uri": "docs://tool-guide",
    "name": "Tool Usage Guide",
    "description": "Instructions for using weather tools",
    "mime_type": "text/markdown",
    "data_source_type": "static",
    "data_source_config": {
      "content": "# Weather Tools Guide\n\nUse `get_weather` for current conditions."
    }
  }
  '
  ```

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

  response = requests.post(
      "https://yoursite.com/wp-json/getmcp/v1/servers/1/resources",
      headers={
          "Authorization": "Bearer gmcp_your_api_key",
          "Content-Type": "application/json"
      },
      json={
          "uri": "docs://tool-guide",
          "name": "Tool Usage Guide",
          "description": "Instructions for using weather tools",
          "mime_type": "text/markdown",
          "data_source_type": "static",
          "data_source_config": {
              "content": "# Weather Tools Guide\n\nUse `get_weather` for current conditions."
          }
      }
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://yoursite.com/wp-json/getmcp/v1/servers/1/resources",
    {
      method: "POST",
      headers: {
        "Authorization": "Bearer gmcp_your_api_key",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        uri: "docs://tool-guide",
        name: "Tool Usage Guide",
        description: "Instructions for using weather tools",
        mime_type: "text/markdown",
        data_source_type: "static",
        data_source_config: {
          content: "# Weather Tools Guide\n\nUse `get_weather` for current conditions."
        }
      })
    }
  );
  const data = await response.json();
  ```

  ```php PHP theme={null}
  $response = wp_remote_post(
      "https://yoursite.com/wp-json/getmcp/v1/servers/1/resources",
      [
          "headers" => [
              "Authorization" => "Bearer gmcp_your_api_key",
              "Content-Type"  => "application/json"
          ],
          "body" => json_encode([
              "uri"                => "docs://tool-guide",
              "name"               => "Tool Usage Guide",
              "description"        => "Instructions for using weather tools",
              "mime_type"          => "text/markdown",
              "data_source_type"   => "static",
              "data_source_config" => [
                  "content" => "# Weather Tools Guide\n\nUse get_weather for current conditions."
              ]
          ])
      ]
  );
  $data = json_decode(wp_remote_retrieve_body($response), true);
  ```

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

  import (
  	"fmt"
  	"io"
  	"net/http"
  	"strings"
  )

  func main() {
  	body := strings.NewReader(`{
    "uri": "docs://tool-guide",
    "name": "Tool Usage Guide",
    "description": "Instructions for using weather tools",
    "mime_type": "text/markdown",
    "data_source_type": "static",
    "data_source_config": {
      "content": "# Weather Tools Guide\n\nUse ` + "`" + `get_weather` + "`" + ` for current conditions."
    }
  }`)

  	req, _ := http.NewRequest("POST", "https://yoursite.com/wp-json/getmcp/v1/servers/1/resources", body)
  	req.Header.Set("Authorization", "Bearer gmcp_your_api_key")
  	req.Header.Set("Content-Type", "application/json")

  	client := &http.Client{}
  	resp, _ := client.Do(req)
  	defer resp.Body.Close()
  	data, _ := io.ReadAll(resp.Body)
  	fmt.Println(string(data))
  }
  ```

  ```java Java theme={null}
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;

  public class Main {
      public static void main(String[] args) throws Exception {
          String json = "{\n  \"uri\": \"docs://tool-guide\",\n  \"name\": \"Tool Usage Guide\",\n  \"description\": \"Instructions for using weather tools\",\n  \"mime_type\": \"text/markdown\",\n  \"data_source_type\": \"static\",\n  \"data_source_config\": {\n    \"content\": \"# Weather Tools Guide\\n\\nUse `get_weather` for current conditions.\"\n  }\n}";

          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://yoursite.com/wp-json/getmcp/v1/servers/1/resources"))
              .header("Authorization", "Bearer gmcp_your_api_key")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(json))
              .build();

          HttpClient client = HttpClient.newHttpClient();
          HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
          System.out.println(response.body());
      }
  }
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

  uri = URI('https://yoursite.com/wp-json/getmcp/v1/servers/1/resources')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = uri.scheme == 'https'

  request = Net::HTTP::Post.new(uri)
  request['Authorization'] = 'Bearer gmcp_your_api_key'
  request['Content-Type'] = 'application/json'
  request.body = '{
    "uri": "docs://tool-guide",
    "name": "Tool Usage Guide",
    "description": "Instructions for using weather tools",
    "mime_type": "text/markdown",
    "data_source_type": "static",
    "data_source_config": {
      "content": "# Weather Tools Guide\n\nUse `get_weather` for current conditions."
    }
  }'

  response = http.request(request)
  puts JSON.parse(response.body)
  ```
</RequestExample>

<ResponseExample>
  ```json 201 Created theme={null}
  {
    "id": 3,
    "server_id": 1,
    "uri": "docs://tool-guide",
    "name": "Tool Usage Guide",
    "description": "Instructions for using weather tools",
    "mime_type": "text/markdown",
    "data_source_type": "static",
    "data_source_config": {
      "content": "# Weather Tools Guide\n\nUse `get_weather` for current conditions."
    },
    "template_uri": null,
    "server_uuid": "836995ae-1cff-41ec-823e-a4f07ccca3a0",
    "created_at": "2025-03-18T10:00:00Z",
    "updated_at": "2025-03-18T10:00:00Z"
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "code": "rest_missing_callback_param",
    "message": "Missing parameter(s): uri, name",
    "data": { "status": 400 }
  }
  ```
</ResponseExample>
