> ## 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 Prompt

> Create a new prompt template within a server.

## Path Parameters

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

## Body Parameters

<ParamField body="name" type="string" required>
  Machine-readable prompt name (e.g., `write_product_description`). Use `snake_case`.
</ParamField>

<ParamField body="description" type="string">
  Description of what this prompt does.
</ParamField>

<ParamField body="arguments" type="array">
  Array of argument objects. Each argument has:

  * `name` (string, required) — argument identifier
  * `description` (string) — what the argument is for
  * `required` (boolean) — whether it must be provided
</ParamField>

<ParamField body="template_content" type="string" required>
  The prompt text with `{{argument_name}}` placeholders.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
       --url https://yoursite.com/wp-json/getmcp/v1/servers/1/prompts \
       --header 'Authorization: Bearer gmcp_your_api_key' \
       --header 'content-type: application/json' \
       --data '
  {
    "name": "summarize_article",
    "description": "Summarize an article in a specified style and length",
    "arguments": [
      {"name": "article_text", "description": "The full article text", "required": true},
      {"name": "style", "description": "Summary style: bullet points or paragraph", "required": false},
      {"name": "max_words", "description": "Maximum word count for the summary", "required": false}
    ],
    "template_content": "Summarize the following article in {{style}} format, keeping it under {{max_words}} words:\n\n{{article_text}}"
  }
  '
  ```

  ```python Python theme={null}
  import requests
  response = requests.post(
      "https://yoursite.com/wp-json/getmcp/v1/servers/1/prompts",
      headers={
          "Authorization": "Bearer gmcp_your_api_key",
          "Content-Type": "application/json"
      },
      json={
          "name": "summarize_article",
          "description": "Summarize an article in a specified style and length",
          "arguments": [
              {"name": "article_text", "description": "The full article text", "required": True},
              {"name": "style", "description": "Summary style", "required": False},
              {"name": "max_words", "description": "Maximum word count", "required": False}
          ],
          "template_content": "Summarize the following article in {{style}} format, keeping it under {{max_words}} words:\n\n{{article_text}}"
      }
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://yoursite.com/wp-json/getmcp/v1/servers/1/prompts",
    {
      method: "POST",
      headers: {
        "Authorization": "Bearer gmcp_your_api_key",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        name: "summarize_article",
        description: "Summarize an article in a specified style and length",
        arguments: [
          { name: "article_text", description: "The full article text", required: true },
          { name: "style", description: "Summary style", required: false },
          { name: "max_words", description: "Maximum word count", required: false }
        ],
        template_content: "Summarize the following article in {{style}} format, keeping it under {{max_words}} words:\n\n{{article_text}}"
      })
    }
  );
  const data = await response.json();
  ```

  ```php PHP theme={null}
  $response = wp_remote_post(
      "https://yoursite.com/wp-json/getmcp/v1/servers/1/prompts",
      [
          "headers" => [
              "Authorization" => "Bearer gmcp_your_api_key",
              "Content-Type"  => "application/json"
          ],
          "body" => json_encode([
              "name"             => "summarize_article",
              "description"      => "Summarize an article in a specified style and length",
              "arguments"        => [
                  ["name" => "article_text", "description" => "The full article text", "required" => true],
                  ["name" => "style", "description" => "Summary style", "required" => false],
                  ["name" => "max_words", "description" => "Maximum word count", "required" => false]
              ],
              "template_content" => "Summarize the following article in {{style}} format, keeping it under {{max_words}} words:\n\n{{article_text}}"
          ])
      ]
  );
  $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(`{
    "name": "summarize_article",
    "description": "Summarize an article in a specified style and length",
    "arguments": [
      {"name": "article_text", "description": "The full article text", "required": true},
      {"name": "style", "description": "Summary style: bullet points or paragraph", "required": false},
      {"name": "max_words", "description": "Maximum word count for the summary", "required": false}
    ],
    "template_content": "Summarize the following article in {{style}} format, keeping it under {{max_words}} words:\n\n{{article_text}}"
  }`)

  	req, _ := http.NewRequest("POST", "https://yoursite.com/wp-json/getmcp/v1/servers/1/prompts", 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  \"name\": \"summarize_article\",\n  \"description\": \"Summarize an article in a specified style and length\",\n  \"arguments\": [\n    {\"name\": \"article_text\", \"description\": \"The full article text\", \"required\": true},\n    {\"name\": \"style\", \"description\": \"Summary style: bullet points or paragraph\", \"required\": false},\n    {\"name\": \"max_words\", \"description\": \"Maximum word count for the summary\", \"required\": false}\n  ],\n  \"template_content\": \"Summarize the following article in {{style}} format, keeping it under {{max_words}} words:\\n\\n{{article_text}}\"\n}";

          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://yoursite.com/wp-json/getmcp/v1/servers/1/prompts"))
              .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/prompts')
  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 = '{
    "name": "summarize_article",
    "description": "Summarize an article in a specified style and length",
    "arguments": [
      {"name": "article_text", "description": "The full article text", "required": true},
      {"name": "style", "description": "Summary style: bullet points or paragraph", "required": false},
      {"name": "max_words", "description": "Maximum word count for the summary", "required": false}
    ],
    "template_content": "Summarize the following article in {{style}} format, keeping it under {{max_words}} words:\n\n{{article_text}}"
  }'

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

<ResponseExample>
  ```json 201 Created theme={null}
  {
    "id": 2,
    "server_id": 1,
    "name": "summarize_article",
    "description": "Summarize an article in a specified style and length",
    "arguments": [
      {"name": "article_text", "description": "The full article text", "required": true},
      {"name": "style", "description": "Summary style", "required": false},
      {"name": "max_words", "description": "Maximum word count", "required": false}
    ],
    "template_content": "Summarize the following article in {{style}} format...",
    "server_uuid": "836995ae-1cff-41ec-823e-a4f07ccca3a0",
    "created_at": "2025-03-18T10:00:00Z",
    "updated_at": "2025-03-18T10:00:00Z"
  }
  ```
</ResponseExample>
