Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions __tests__/client/utilities/getMediaURL.client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ describe('client-side utilities: getMediaURL', () => {
expect(result).toBe(expectedUrl)
})

it('handles URLs with query parameters correctly', () => {
it('appends cache tag with & when URL already has a query string', () => {
const relativeUrl = '/images/photo.jpg?existing=param'
const cacheTag = 'v789'
const result = getMediaURL(relativeUrl, cacheTag)
const expectedUrl = `${window.location.origin}${relativeUrl}?${cacheTag}`
const expectedUrl = `${window.location.origin}${relativeUrl}&${cacheTag}`
expect(result).toBe(expectedUrl)
})
})
11 changes: 9 additions & 2 deletions __tests__/server/getMediaURL.server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,18 @@ describe('server-side utilities: getMediaURL', () => {
expect(result).toBe('http://customhostname.com/images/photo.jpg')
})

it('handles URLs with query parameters correctly', () => {
it('appends cache tag with & when URL already has a query string', () => {
const relativeUrl = '/images/photo.jpg?existing=param'
const cacheTag = 'v789'
const result = getMediaURL(relativeUrl, cacheTag)
expect(result).toBe('http://envvar.localhost:3000/images/photo.jpg?existing=param?v789')
expect(result).toBe('http://envvar.localhost:3000/images/photo.jpg?existing=param&v789')
})

it('appends cache tag with & on absolute URL with existing query string', () => {
const absoluteUrl = 'https://example.com/image.jpg?prefix=local'
const cacheTag = 'v123'
const result = getMediaURL(absoluteUrl, cacheTag)
expect(result).toBe('https://example.com/image.jpg?prefix=local&v123')
})

it('handles ftp protocol URLs as absolute', () => {
Expand Down
1 change: 1 addition & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference path="./.next/types/routes.d.ts" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
40 changes: 22 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@
"@libsql/client": "^0.17.2",
"@open-iframe-resizer/core": "^2.1.0",
"@open-iframe-resizer/react": "^2.1.0",
"@payloadcms/admin-bar": "3.81.0",
"@payloadcms/db-sqlite": "3.81.0",
"@payloadcms/email-nodemailer": "3.81.0",
"@payloadcms/email-resend": "3.81.0",
"@payloadcms/next": "3.81.0",
"@payloadcms/plugin-form-builder": "3.81.0",
"@payloadcms/plugin-mcp": "3.81.0",
"@payloadcms/plugin-sentry": "3.81.0",
"@payloadcms/plugin-seo": "3.81.0",
"@payloadcms/richtext-lexical": "3.81.0",
"@payloadcms/storage-vercel-blob": "3.81.0",
"@payloadcms/ui": "3.81.0",
"@payloadcms/admin-bar": "3.84.1",
"@payloadcms/db-sqlite": "3.84.1",
"@payloadcms/email-nodemailer": "3.84.1",
"@payloadcms/email-resend": "3.84.1",
"@payloadcms/next": "3.84.1",
"@payloadcms/plugin-form-builder": "3.84.1",
"@payloadcms/plugin-mcp": "3.84.1",
"@payloadcms/plugin-sentry": "3.84.1",
"@payloadcms/plugin-seo": "3.84.1",
"@payloadcms/richtext-lexical": "3.84.1",
"@payloadcms/storage-vercel-blob": "3.84.1",
"@payloadcms/ui": "3.84.1",
"@radix-ui/react-accordion": "^1.2.4",
"@radix-ui/react-avatar": "^1.1.7",
"@radix-ui/react-checkbox": "^1.1.3",
Expand All @@ -86,7 +86,7 @@
"@vercel/blob": "^2.3.3",
"@vercel/edge-config": "^1.4.0",
"@vercel/og": "^0.11.1",
"axios": "1.14.0",
"axios": "1.15.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cross-env": "^7.0.3",
Expand All @@ -101,12 +101,12 @@
"libsql": "^0.5.6",
"lodash-es": "^4.18.1",
"lucide-react": "^1.7.0",
"next": "15.4.11",
"next": "15.5.15",
"next-sitemap": "^4.2.3",
"nextjs-toploader": "^3.9.17",
"nuqs": "^2.7.3",
"path-to-regexp": "^8.4.2",
"payload": "3.81.0",
"payload": "3.84.1",
"pino": "9.14.0",
"pino-pretty": "13.1.3",
"pluralize": "^8.0.0",
Expand All @@ -124,7 +124,7 @@
"tailwind-merge": "^3.4.0",
"tailwindcss-animate": "^1.0.7",
"tiny-invariant": "^1.3.3",
"uuid": "^11.1.0",
"uuid": "^14.0.0",
"zod": "^3.24.4"
},
"devDependencies": {
Expand Down Expand Up @@ -155,7 +155,7 @@
"jest-environment-jsdom": "^30.0.0",
"lint-staged": "^16.4.0",
"msw": "^2.13.4",
"postcss": "^8.4.49",
"postcss": "^8.5.10",
"prettier": "^3.4.2",
"prettier-plugin-organize-imports": "^4.1.0",
"react-email": "5.2.10",
Expand All @@ -178,6 +178,10 @@
"patchedDependencies": {
"@payloadcms/storage-vercel-blob": "patches/@payloadcms__storage-vercel-blob.patch",
"@payloadcms/plugin-mcp": "patches/@payloadcms__plugin-mcp.patch"
}
},
"ignoredBuiltDependencies": [
"msw",
"protobufjs"
]
}
}
87 changes: 4 additions & 83 deletions patches/@payloadcms__plugin-mcp.patch
Original file line number Diff line number Diff line change
@@ -1,35 +1,8 @@
diff --git a/dist/endpoints/mcp.js b/dist/endpoints/mcp.js
index 7b6b62d82ed708d679e329d43c424595c39b81b1..764f6ab9c63d1cbea0e5a0c54f44396120c0261e 100644
--- a/dist/endpoints/mcp.js
+++ b/dist/endpoints/mcp.js
@@ -22,7 +22,7 @@ export const initializeMCPHandler = (pluginOptions)=>{
};
const { docs } = await payload.find({
collection: 'payload-mcp-api-keys',
- depth: 1,
+ depth: pluginOptions.authDepth ?? 1,
limit: 1,
pagination: false,
where
diff --git a/dist/mcp/getMcpHandler.js b/dist/mcp/getMcpHandler.js
index d69079472a3d58d6d1fb5958de20437de7863c4c..c321ae4d10f45d03204221e8bbac0b3503faa0a4 100644
--- a/dist/mcp/getMcpHandler.js
+++ b/dist/mcp/getMcpHandler.js
@@ -213,7 +213,8 @@ export const getMCPHandler = (pluginOptions, mcpAccessSettings, req)=>{
payload.logger.info('[payload-mcp] 🚀 MCP Server Ready.');
}
}, {
- serverInfo: serverOptions.serverInfo
+ serverInfo: serverOptions.serverInfo,
+ instructions: serverOptions.instructions
}, {
basePath: MCPHandlerOptions.basePath || payload.config.routes?.api || '/api',
disableSse: MCPHandlerOptions.disableSse ?? true,
diff --git a/dist/types.d.ts b/dist/types.d.ts
index 09019905cdd448c0235dab94d36c13f85f6b9e2d..a96817d7b2dd2908563c0cd3b9cede5692418ac9 100644
index 4d71adff1756e5bbdc880ac0edc6b6ad9fee1d4a..07f8ed3c93bc4362bec35d3d9355176c1443c697 100644
--- a/dist/types.d.ts
+++ b/dist/types.d.ts
@@ -260,6 +260,13 @@ export type PluginMCPServerConfig = {
@@ -260,6 +260,13 @@ export type MCPPluginConfig = {
parameters: z.ZodRawShape;
}[];
};
Expand All @@ -43,49 +16,11 @@ index 09019905cdd448c0235dab94d36c13f85f6b9e2d..a96817d7b2dd2908563c0cd3b9cede56
/**
* Override the API key collection.
* This allows you to add fields to the API key collection or modify the collection in any way you want.
@@ -333,6 +340,12 @@ export type MCPServerOptions = {
*/
version: string;
};
+ /**
+ * Optional instructions describing how to use the server and its features.
+ * These are returned to MCP clients during initialization and may be added
+ * to the LLM's system prompt.
+ */
+ instructions?: string;
};
export type MCPAccessSettings = {
auth?: {
diff --git a/src/endpoints/mcp.ts b/src/endpoints/mcp.ts
index ee9d484fcb20784894bb0e5b7d910f9bf084e36b..d1ba435b3f5742b44b6ac3c41c9fb4e83b9fc982 100644
--- a/src/endpoints/mcp.ts
+++ b/src/endpoints/mcp.ts
@@ -38,7 +38,7 @@ export const initializeMCPHandler = (pluginOptions: PluginMCPServerConfig) => {

const { docs } = await payload.find({
collection: 'payload-mcp-api-keys',
- depth: 1,
+ depth: pluginOptions.authDepth ?? 1,
limit: 1,
pagination: false,
where,
diff --git a/src/mcp/getMcpHandler.ts b/src/mcp/getMcpHandler.ts
index 5e9ac74e7c553489810ec2ad01dac1f626b4270d..01eb665872547e0926d323d29ec829cac22cc4db 100644
--- a/src/mcp/getMcpHandler.ts
+++ b/src/mcp/getMcpHandler.ts
@@ -528,6 +528,7 @@ export const getMCPHandler = (
},
{
serverInfo: serverOptions.serverInfo,
+ instructions: serverOptions.instructions,
},
{
basePath: MCPHandlerOptions.basePath || payload.config.routes?.api || '/api',
diff --git a/src/types.ts b/src/types.ts
index fcea1a2c1863bdf7d02c09a176bdf64c1507ad4f..9f217edcb9b251b38dfea26e0c813ea5e55b8a62 100644
index 356c7271a0b850138801225700ffeb5ffd658c3e..3df7326cd17d3d3556fa1d749ea12713e53a5b9a 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -308,6 +308,14 @@ export type PluginMCPServerConfig = {
@@ -308,6 +308,14 @@ export type MCPPluginConfig = {
}[]
}

Expand All @@ -100,17 +35,3 @@ index fcea1a2c1863bdf7d02c09a176bdf64c1507ad4f..9f217edcb9b251b38dfea26e0c813ea5
/**
* Override the API key collection.
* This allows you to add fields to the API key collection or modify the collection in any way you want.
@@ -388,6 +396,13 @@ export type MCPServerOptions = {
*/
version: string
}
+
+ /**
+ * Optional instructions describing how to use the server and its features.
+ * These are returned to MCP clients during initialization and may be added
+ * to the LLM's system prompt.
+ */
+ instructions?: string
}

export type MCPAccessSettings = {
Loading
Loading