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; id: string;
name: string; name: string;
image: string | null; image: string | null;
username: string | null;
}; };
} }
@ -202,7 +203,12 @@ export default function PublicAgentsPage(): React.ReactElement {
</Link> </Link>
</td> </td>
<td className="px-4 py-3 text-right"> <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> </td>
</> </>
); );

View file

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

View file

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

View file

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

View file

@ -86,12 +86,13 @@ export function CopyDropdown({
// Helper functions to generate copy options for different entity types // Helper functions to generate copy options for different entity types
export function getCollectionCopyOptions( export function getCollectionCopyOptions(
collectionId: string, username: string,
slug: string,
collectionName: string collectionName: string
): CopyOption[] { ): CopyOption[] {
const baseUrl = 'https://tpmjs.com'; const baseUrl = 'https://tpmjs.com';
const mcpUrlHttp = `${baseUrl}/mcp/collections/${collectionId}`; const mcpUrlHttp = `${baseUrl}/api/mcp/${username}/${slug}/http`;
const mcpUrlSse = `${baseUrl}/mcp/collections/${collectionId}/sse`; const mcpUrlSse = `${baseUrl}/api/mcp/${username}/${slug}/sse`;
const claudeConfig = JSON.stringify( 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 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( const claudeConfig = JSON.stringify(
{ {
mcpServers: { mcpServers: {
[agentName.toLowerCase().replace(/\s+/g, '-')]: { [agentName.toLowerCase().replace(/\s+/g, '-')]: {
command: 'npx', 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 [ return [
{ label: 'Agent UID', value: agentUid, description: agentUid }, { 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', label: 'Claude Config',
value: claudeConfig, value: claudeConfig,