fix: update MCP copy URLs to use new /api/mcp/{username}/{slug} format

- Update getCollectionCopyOptions to require username and slug params
- Update getAgentCopyOptions to require username param
- Add slug and username to public collections/agents API responses
- Remove deprecated /mcp/collections/{id} and /mcp/agents/{uid} URL formats
This commit is contained in:
Ajax Davis 2026-01-09 08:14:39 +10:00
parent ad3457ab32
commit 8c6185e6bb
6 changed files with 36 additions and 13 deletions

View file

@ -1 +0,0 @@
# Trigger deployment 1767909608

View file

@ -28,6 +28,7 @@ interface PublicAgent {
id: string;
name: string;
image: string | null;
username: string | null;
};
}
@ -202,7 +203,12 @@ export default function PublicAgentsPage(): React.ReactElement {
</Link>
</td>
<td className="px-4 py-3 text-right">
<CopyDropdown options={getAgentCopyOptions(agent.uid, agent.name)} buttonLabel="Copy" />
{agent.createdBy.username && (
<CopyDropdown
options={getAgentCopyOptions(agent.createdBy.username, agent.uid, agent.name)}
buttonLabel="Copy"
/>
)}
</td>
</>
);

View file

@ -61,6 +61,7 @@ export async function GET(request: NextRequest): Promise<NextResponse<ApiRespons
id: true,
name: true,
image: true,
username: true,
},
},
_count: {

View file

@ -61,6 +61,7 @@ export async function GET(request: NextRequest): Promise<NextResponse<ApiRespons
id: true,
name: true,
image: true,
username: true,
},
},
_count: {
@ -79,6 +80,7 @@ export async function GET(request: NextRequest): Promise<NextResponse<ApiRespons
success: true,
data: data.map((collection) => ({
id: collection.id,
slug: collection.slug,
name: collection.name,
description: collection.description,
likeCount: collection.likeCount,

View file

@ -15,6 +15,7 @@ import { LikeButton } from '~/components/LikeButton';
interface PublicCollection {
id: string;
slug: string;
name: string;
description: string | null;
likeCount: number;
@ -24,6 +25,7 @@ interface PublicCollection {
id: string;
name: string;
image: string | null;
username: string | null;
};
}
@ -179,10 +181,16 @@ export default function PublicCollectionsPage(): React.ReactElement {
</div>
</td>
<td className="px-4 py-3 text-right">
<CopyDropdown
options={getCollectionCopyOptions(collection.id, collection.name)}
buttonLabel="Copy"
/>
{collection.createdBy.username && (
<CopyDropdown
options={getCollectionCopyOptions(
collection.createdBy.username,
collection.slug,
collection.name
)}
buttonLabel="Copy"
/>
)}
</td>
</>
);

View file

@ -86,12 +86,13 @@ export function CopyDropdown({
// Helper functions to generate copy options for different entity types
export function getCollectionCopyOptions(
collectionId: string,
username: string,
slug: string,
collectionName: string
): CopyOption[] {
const baseUrl = 'https://tpmjs.com';
const mcpUrlHttp = `${baseUrl}/mcp/collections/${collectionId}`;
const mcpUrlSse = `${baseUrl}/mcp/collections/${collectionId}/sse`;
const mcpUrlHttp = `${baseUrl}/api/mcp/${username}/${slug}/http`;
const mcpUrlSse = `${baseUrl}/api/mcp/${username}/${slug}/sse`;
const claudeConfig = JSON.stringify(
{
@ -117,16 +118,21 @@ export function getCollectionCopyOptions(
];
}
export function getAgentCopyOptions(agentUid: string, agentName: string): CopyOption[] {
export function getAgentCopyOptions(
username: string,
agentUid: string,
agentName: string
): CopyOption[] {
const baseUrl = 'https://tpmjs.com';
const mcpUrl = `${baseUrl}/mcp/agents/${agentUid}`;
const mcpUrlHttp = `${baseUrl}/api/mcp/${username}/${agentUid}/http`;
const mcpUrlSse = `${baseUrl}/api/mcp/${username}/${agentUid}/sse`;
const claudeConfig = JSON.stringify(
{
mcpServers: {
[agentName.toLowerCase().replace(/\s+/g, '-')]: {
command: 'npx',
args: ['-y', '@anthropic-ai/mcp-remote', mcpUrl],
args: ['-y', '@anthropic-ai/mcp-remote', mcpUrlSse],
},
},
},
@ -136,7 +142,8 @@ export function getAgentCopyOptions(agentUid: string, agentName: string): CopyOp
return [
{ label: 'Agent UID', value: agentUid, description: agentUid },
{ label: 'MCP URL', value: mcpUrl, description: mcpUrl },
{ label: 'MCP URL (HTTP)', value: mcpUrlHttp, description: mcpUrlHttp },
{ label: 'MCP URL (SSE)', value: mcpUrlSse, description: mcpUrlSse },
{
label: 'Claude Config',
value: claudeConfig,