MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / handleResourceRead

Method handleResourceRead

server/src/mcp-tools.ts:1938–2071  ·  view source on GitHub ↗

* Handle a resource read request.

(uri: string)

Source from the content-addressed store, hash-verified

1936 * Handle a resource read request.
1937 */
1938 async handleResourceRead(uri: string): Promise<{
1939 contents: Array<{ uri: string; mimeType: string; text: string }>;
1940 }> {
1941 // Handle SI agent UI resource (MCP Apps)
1942 const siMatch = uri.match(/^ui:\/\/si\/(.+)$/);
1943 if (siMatch) {
1944 const sessionId = siMatch[1];
1945 return this.handleSiUiResource(uri, sessionId);
1946 }
1947
1948 // Handle members resource
1949 if (uri === "members://directory") {
1950 const members = await this.memberDb.getPublicProfiles({});
1951 const simplified = members.map((m) => ({
1952 slug: m.slug,
1953 display_name: m.display_name,
1954 tagline: m.tagline,
1955 offerings: m.offerings,
1956 headquarters: m.headquarters,
1957 agents_count: m.agents.filter((a) => a.visibility === 'public').length,
1958 publishers_count: (m.publishers || []).filter((p) => p.is_public).length,
1959 }));
1960
1961 return {
1962 contents: [
1963 {
1964 uri,
1965 mimeType: "application/json",
1966 text: JSON.stringify(simplified, null, 2),
1967 },
1968 ],
1969 };
1970 }
1971
1972 // Handle publishers resource
1973 if (uri === "publishers://all") {
1974 const members = await this.memberDb.getPublicProfiles({});
1975 const publishers = members.flatMap((m) =>
1976 (m.publishers || [])
1977 .filter((p) => p.is_public)
1978 .map((p) => ({
1979 domain: p.domain,
1980 agent_count: p.agent_count,
1981 last_validated: p.last_validated,
1982 member: {
1983 slug: m.slug,
1984 display_name: m.display_name,
1985 },
1986 }))
1987 );
1988
1989 return {
1990 contents: [
1991 {
1992 uri,
1993 mimeType: "application/json",
1994 text: JSON.stringify(publishers, null, 2),
1995 },

Callers 2

createMCPServerFunction · 0.95
createUnifiedMCPServerFunction · 0.80

Calls 5

handleSiUiResourceMethod · 0.95
getPublicProfilesMethod · 0.80
listAgentsMethod · 0.80

Tested by

no test coverage detected