Tools Reference

Complete reference for all 5 MCP tools provided by snippets-mcp.

Snippets-mcp provides 5 MCP tools for full CRUD operations on GitHub Gists.

list_snippets

List code snippets with optional filtering.

Parameters

ParameterTypeRequiredDescription
visibilitystringnoFilter: all, public, or private
languagestringnoFilter by programming language (e.g., Go, Python)
searchstringnoSearch term in snippet description
tagstringnoFilter by hashtag (e.g., go matches #go)
limitintegernoMaximum results (default: 30)
offsetintegernoPagination offset

Example Request

{
  "visibility": "private",
  "language": "Go",
  "tag": "utility",
  "limit": 10
}

Example Response

{
  "snippets": [
    {
      "id": "abc123",
      "description": "String helpers #go #utility",
      "tags": ["go", "utility"],
      "files": ["strings.go"],
      "public": false,
      "updated_at": "2025-01-15T10:00:00Z"
    }
  ],
  "total": 42
}

get_snippet

Retrieve full content of a snippet by ID.

Parameters

ParameterTypeRequiredDescription
idstringyesGist ID

Example Request

{
  "id": "abc123"
}

Example Response

{
  "id": "abc123",
  "description": "String helpers #go #utility",
  "public": false,
  "files": [
    {
      "filename": "strings.go",
      "language": "Go",
      "content": "package strings\n\nfunc Reverse(s string) string {\n\t...\n}",
      "size": 256,
      "truncated": false
    }
  ],
  "html_url": "https://gist.github.com/user/abc123",
  "created_at": "2025-01-10T08:00:00Z",
  "updated_at": "2025-01-15T10:00:00Z"
}

create_snippet

Create a new code snippet (GitHub Gist).

Parameters

ParameterTypeRequiredDescription
descriptionstringnoSnippet description (include #tags here)
publicbooleannoMake public (default: false)
filesarrayyesFiles to include

Each file in the files array:

FieldTypeRequiredDescription
filenamestringyesName of the file
contentstringyesFile contents

Example Request

{
  "description": "HTTP client helper #go #http",
  "public": false,
  "files": [
    {
      "filename": "client.go",
      "content": "package http\n\nimport \"net/http\"\n\nfunc Get(url string) (*http.Response, error) {\n\treturn http.Get(url)\n}"
    }
  ]
}

Example Response

{
  "id": "def456",
  "description": "HTTP client helper #go #http",
  "html_url": "https://gist.github.com/user/def456"
}

update_snippet

Update an existing snippet.

Parameters

ParameterTypeRequiredDescription
idstringyesSnippet ID to update
descriptionstringnoNew description
filesarraynoFiles to add or update
remove_filesarraynoFilenames to remove

Example Request

Update description and file content:

{
  "id": "abc123",
  "description": "Updated string helpers #go #utility #strings",
  "files": [
    {
      "filename": "strings.go",
      "content": "// Updated content\npackage strings\n\nfunc Reverse(s string) string {\n\trunes := []rune(s)\n\tfor i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {\n\t\trunes[i], runes[j] = runes[j], runes[i]\n\t}\n\treturn string(runes)\n}"
    }
  ]
}

Remove a file:

{
  "id": "abc123",
  "remove_files": ["old_file.txt"]
}

Example Response

{
  "id": "abc123",
  "description": "Updated string helpers #go #utility #strings",
  "html_url": "https://gist.github.com/user/abc123"
}

delete_snippet

Permanently delete a snippet.

Parameters

ParameterTypeRequiredDescription
idstringyesSnippet ID to delete
confirmbooleanyesMust be true to confirm deletion

The confirm parameter prevents accidental deletions.

Example Request

{
  "id": "abc123",
  "confirm": true
}

Example Response

{
  "deleted": true,
  "id": "abc123"
}

Hashtag Tagging

GitHub Gists don’t natively support tags. Snippets-mcp extracts hashtags from the description field.

Format

Include hashtags in your description:

API client for GitHub #go #api #http

Rules

  • Tags start with # followed by a letter
  • Can contain letters, numbers, underscores, and hyphens
  • Case-insensitive: #Go, #GO, #go are equivalent
  • Issue references like #123 are ignored

Filtering

Use the tag parameter without the #:

{"tag": "go"}

This matches any snippet with #go, #Go, or #GO in its description.