Skip to content

Commit fb2ce63

Browse files
committed
Fix serverName references
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
1 parent 7e87def commit fb2ce63

File tree

6 files changed

+72
-17
lines changed

6 files changed

+72
-17
lines changed

docs/guides/consuming/use-rest-api.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Integration patterns and best practices for building applications that consume M
99
**Authentication**: Not required for read-only access
1010

1111
- **`GET /v0/servers`** - List all servers with pagination
12-
- **`GET /v0/servers/{server_id}`** - Get latest version of server by server ID
13-
- **`GET /v0/servers/{server_id}?version=X.X.X`** - Get specific version of server
14-
- **`GET /v0/servers/{server_id}/versions`** - List all versions of a server
12+
- **`GET /v0/servers/{serverName}`** - Get latest version of server by server name (URL-encoded)
13+
- **`GET /v0/servers/{serverName}/versions/{version}`** - Get specific version of server
14+
- **`GET /v0/servers/{serverName}/versions`** - List all versions of a server
1515

1616
See the [interactive API documentation](https://registry.modelcontextprotocol.io/docs) for complete request/response schemas.
1717

@@ -22,6 +22,32 @@ See the [interactive API documentation](https://registry.modelcontextprotocol.io
2222

2323
For now we recommend scraping the `GET /v0/servers` endpoint on some regular basis. In the future we might provide a filter for updatedAt ([#291](https://github.com/modelcontextprotocol/registry/issues/291)) to get only recently changed servers.
2424

25+
### Pagination Example
26+
27+
The API uses cursor-based pagination. Here's how to fetch all servers:
28+
29+
```bash
30+
# Initial request
31+
curl "https://registry.modelcontextprotocol.io/v0/servers?limit=100"
32+
```
33+
34+
```json
35+
{
36+
"servers": [...],
37+
"metadata": {
38+
"count": 100,
39+
"nextCursor": "com.example/my-server:1.0.0"
40+
}
41+
}
42+
```
43+
44+
```bash
45+
# Next page using cursor
46+
curl "https://registry.modelcontextprotocol.io/v0/servers?limit=100&cursor=com.example%2Fmy-server%3A1.0.0"
47+
```
48+
49+
**Important**: Always URL-encode cursor values when using them in query parameters.
50+
2551
Servers are generally immutable, except for the `status` field which can be updated to `deleted` (among other states). For these packages, we recommend you also update the status field to `deleted` or remove the package from your registry quickly. This is because this status generally indicates it has violated our permissive [moderation guidelines](../administration/moderation-guidelines.md), suggesting it is illegal, malware or spam.
2652

2753
### Filtering & Enhancement

docs/reference/api/CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ Changes to the REST API endpoints and responses.
1111
API endpoints updated to use server names instead of server IDs for better usability.
1212

1313
**Changed endpoints:**
14-
- `GET /v0/servers/{server_id}``GET /v0/servers/{server_name}`
15-
- `GET /v0/servers/{server_id}/versions``GET /v0/servers/{server_name}/versions`
14+
- `GET /v0/servers/{server_id}``GET /v0/servers/{serverName}`
15+
- `GET /v0/servers/{server_id}/versions``GET /v0/servers/{serverName}/versions`
1616

1717
**New endpoints:**
18-
- `GET /v0/servers/{server_name}/versions/{version}` - Get specific server version
19-
- `PUT /v0/servers/{server_name}/versions/{version}` - Edit server version (admin only)
18+
- `GET /v0/servers/{serverName}/versions/{version}` - Get specific server version
19+
- `PUT /v0/servers/{serverName}/versions/{version}` - Edit server version (admin only)
2020

2121
**Response format changes:**
2222
- Introduced `ServerResponse` schema separating server data from registry metadata

docs/reference/api/generic-registry-api.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ The official registry has some more endpoints and restrictions on top of this. S
1515

1616
### Core Endpoints
1717
- **`GET /v0/servers`** - List all servers with pagination
18-
- **`GET /v0/servers/{server_name}`** - Get latest version of server by server name (URL-encoded)
19-
- **`GET /v0/servers/{server_name}/versions/{version}`** - Get specific version of server (both parameters should be URL-encoded)
20-
- **`GET /v0/servers/{server_name}/versions`** - List all versions of a server
18+
- **`GET /v0/servers/{serverName}`** - Get latest version of server by server name (URL-encoded)
19+
- **`GET /v0/servers/{serverName}/versions/{version}`** - Get specific version of server (both parameters should be URL-encoded)
20+
- **`GET /v0/servers/{serverName}/versions`** - List all versions of a server
2121
- **`POST /v0/publish`** - Publish new server (optional, registry-specific authentication)
2222

2323
### Authentication
@@ -27,6 +27,21 @@ The official registry has some more endpoints and restrictions on top of this. S
2727
### Content Type
2828
All requests and responses use `application/json`
2929

30+
### Pagination
31+
List endpoints use cursor-based pagination for efficient, stable results.
32+
33+
#### Cursor Format
34+
Pagination cursors use the format: `{serverName}:{version}`
35+
36+
**Example cursor**: `"com.example/my-server:1.0.0"`
37+
38+
#### Usage
39+
1. **Initial request**: Omit the `cursor` parameter
40+
2. **Subsequent requests**: Use the `nextCursor` value from the previous response
41+
3. **End of results**: When `nextCursor` is null or empty, there are no more results
42+
43+
**Important**: Always treat cursors as opaque strings. Never manually construct or modify cursor values.
44+
3045
### Basic Example: List Servers
3146

3247
```bash
@@ -53,7 +68,7 @@ curl https://registry.example.com/v0/servers?limit=10
5368
],
5469
"metadata": {
5570
"count": 10,
56-
"next_cursor": "eyJ..."
71+
"nextCursor": "com.example/my-server:1.0.0"
5772
}
5873
}
5974
```

docs/reference/api/official-registry-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ Example: `GET /v0/servers?search=filesystem&updated_since=2025-08-01T00:00:00Z&v
5858
#### Admin endpoints
5959
- GET `/metrics` - Prometheus metrics endpoint
6060
- GET `/v0/health` - Basic health check endpoint
61-
- PUT `/v0/servers/{server_name}/versions/{version}` - Edit specific server version
61+
- PUT `/v0/servers/{serverName}/versions/{version}` - Edit specific server version

docs/reference/api/openapi.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ paths:
1919
parameters:
2020
- name: cursor
2121
in: query
22-
description: Pagination cursor for retrieving next set of results
22+
description: |
23+
Pagination cursor for retrieving next set of results.
24+
25+
**Cursor Format**: `{serverName}:{version}`
26+
27+
Example: `"com.example/my-server:1.0.0"`
28+
29+
Cursors are opaque strings returned in the `metadata.nextCursor` field of paginated responses. Always use the exact cursor value returned by the API.
2330
required: false
2431
schema:
2532
type: string
33+
example: "com.example/my-server:1.0.0"
2634
- name: limit
2735
in: query
2836
description: Maximum number of items to return
@@ -306,7 +314,13 @@ components:
306314
properties:
307315
nextCursor:
308316
type: string
309-
description: Cursor for next page of results
317+
description: |
318+
Pagination cursor for retrieving the next page of results.
319+
320+
**Format**: `{serverName}:{version}` (e.g., "com.example/my-server:1.0.0")
321+
322+
Use this exact value in the `cursor` query parameter of your next request. If null or empty, there are no more results.
323+
example: "com.example/my-server:1.0.0"
310324
count:
311325
type: integer
312326
description: Number of items in current page

internal/database/postgres.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ func (db *PostgreSQL) ListServers(
133133
}
134134
}
135135

136-
// Add cursor pagination using compound server_name:version cursor
136+
// Add cursor pagination using compound serverName:version cursor
137137
if cursor != "" {
138-
// Parse cursor format: "server_name:version"
138+
// Parse cursor format: "serverName:version"
139139
parts := strings.SplitN(cursor, ":", 2)
140140
if len(parts) == 2 {
141141
cursorServerName := parts[0]
@@ -213,7 +213,7 @@ func (db *PostgreSQL) ListServers(
213213
return nil, "", fmt.Errorf("error iterating rows: %w", err)
214214
}
215215

216-
// Determine next cursor using compound server_name:version format
216+
// Determine next cursor using compound serverName:version format
217217
nextCursor := ""
218218
if len(results) > 0 && len(results) >= limit {
219219
lastResult := results[len(results)-1]

0 commit comments

Comments
 (0)