Skip to content

Commit 6ebdd97

Browse files
committed
return searchable_content, not attachments
1 parent 4b9a632 commit 6ebdd97

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

mcp/src/apis/search.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export const searchFactory: ApiFactory<
119119
const createQuery = async (type: 'semantic' | 'keyword') =>
120120
pgPool.query<Message>(
121121
`SELECT
122-
${getMessageFields({ includeFiles, coerceType: true })}
122+
${getMessageFields({ includeFiles, coerceType: true, includeAttachments: false, includeSearchableContent: true })}
123123
FROM slack.message_vanilla
124124
WHERE searchable_content != ''
125125
AND (($1::TEXT[] IS NULL) OR (user_id = ANY($1)))
@@ -213,5 +213,6 @@ const getResultMessages = (
213213
message.permalink = includePermalinks
214214
? generatePermalink(message)
215215
: message.permalink;
216+
message.searchable_content = message.searchable_content?.trim();
216217
return normalizeMessageTs(message);
217218
}) || [];

mcp/src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ export const zMessage = z.object({
8484
attachments: z.array(zAttachment).nullish(),
8585
files: z.array(zFile).optional().nullish(),
8686
text: z.string().describe('The text content of the message'),
87+
searchable_content: z
88+
.string()
89+
.nullish()
90+
.describe(
91+
'This is a concatenation of the text field and text content elements from the attachments field. This content is what is used in hybrid search matching.',
92+
),
8793
user_id: z
8894
.string()
8995
.nullable()

mcp/src/util/messageFields.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ export function getMessageFields({
22
coerceType = true,
33
includeAttachments = true,
44
includeFiles,
5+
includeSearchableContent = false,
56
messageTableAlias,
67
}: {
78
coerceType?: boolean;
89
includeAttachments?: boolean;
910
includeFiles?: boolean;
11+
includeSearchableContent?: boolean;
1012
messageTableAlias?: string;
1113
}): string | string[] {
1214
const res = [
@@ -19,6 +21,9 @@ export function getMessageFields({
1921
? [`attachments${coerceType ? '::jsonb' : ''}`]
2022
: []),
2123
...(includeFiles ? [`files${coerceType ? '::jsonb' : ''}`] : []),
24+
...(includeSearchableContent
25+
? [`searchable_content${coerceType ? '::text' : ''}`]
26+
: []),
2227
].map((x) => `${messageTableAlias ? `${messageTableAlias}.${x}` : x}`);
2328

2429
return res.join(',');

0 commit comments

Comments
 (0)