Skip to content

Commit fb8d0a4

Browse files
committed
Added publishImage tool; added missing 'describe' attributes; updated graphlit-client.
1 parent 6d944bf commit fb8d0a4

File tree

4 files changed

+73
-26
lines changed

4 files changed

+73
-26
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ For any questions on using the MCP Server, please join our [Discord](https://dis
4646

4747
- Extract Structured JSON from Text
4848

49+
### Publishing
50+
51+
- Publish as Audio (ElevenLabs Audio)
52+
- Publish as Image (OpenAI Image Generation)
53+
4954
### Ingestion
5055

5156
- Files

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"license": "MIT",
4747
"dependencies": {
4848
"@modelcontextprotocol/sdk": "^1.9.0",
49-
"graphlit-client": "^1.0.20250420001"
49+
"graphlit-client": "^1.0.20250423001"
5050
},
5151
"devDependencies": {
5252
"@types/mime-types": "^2.1.4",

src/tools.ts

+63-21
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import {
2929
IntegrationServiceTypes,
3030
TwitterListingTypes,
3131
ConversationSearchTypes,
32-
PromptStrategyTypes
32+
PromptStrategyTypes,
33+
OpenAiImageModels
3334
} from "graphlit-client/dist/generated/graphql-types.js";
3435

3536
export function registerTools(server: McpServer) {
@@ -2958,7 +2959,7 @@ export function registerTools(server: McpServer) {
29582959
`Screenshots web page from URL.
29592960
Executes *synchronously* and returns the content identifier.`,
29602961
{
2961-
url: z.string()
2962+
url: z.string().describe("Web page URL.")
29622963
},
29632964
async ({ url }) => {
29642965
const client = new Graphlit();
@@ -2994,8 +2995,8 @@ export function registerTools(server: McpServer) {
29942995
Accepts image URL as string.
29952996
Returns Markdown text from LLM completion.`,
29962997
{
2997-
prompt: z.string(),
2998-
url: z.string()
2998+
prompt: z.string().describe("Prompt for image description."),
2999+
url: z.string().describe("Image URL.")
29993000
},
30003001
async ({ prompt, url }) => {
30013002
const client = new Graphlit();
@@ -3029,8 +3030,8 @@ export function registerTools(server: McpServer) {
30293030
Accepts content identifier as string, and optional prompt for image description.
30303031
Returns Markdown text from LLM completion.`,
30313032
{
3032-
id: z.string(),
3033-
prompt: z.string().optional(),
3033+
id: z.string().describe("Content identifier."),
3034+
prompt: z.string().optional().describe("Prompt for image description, optional."),
30343035
},
30353036
async ({ prompt, id }) => {
30363037
const client = new Graphlit();
@@ -3094,10 +3095,10 @@ export function registerTools(server: McpServer) {
30943095
You *must* retrieve the content resource to get the downloadable audio URL for this published audio.
30953096
Executes *synchronously* and returns the content identifier.`,
30963097
{
3097-
name: z.string(),
3098-
text: z.string(),
3099-
textType: z.nativeEnum(TextTypes).optional().default(TextTypes.Markdown),
3100-
voice: z.string().optional().default("HqW11As4VRPkApNPkAZp"),
3098+
name: z.string().describe("Name for the content object."),
3099+
text: z.string().describe("Text content to publish."),
3100+
textType: z.nativeEnum(TextTypes).optional().default(TextTypes.Markdown).describe("Text type (Plain, Markdown, Html). Defaults to Markdown."),
3101+
voice: z.string().optional().default("HqW11As4VRPkApNPkAZp").describe("ElevenLabs voice identifier, optional."),
31013102
},
31023103
async ({ name, text, textType, voice }) => {
31033104
const client = new Graphlit();
@@ -3129,16 +3130,57 @@ export function registerTools(server: McpServer) {
31293130
}
31303131
);
31313132

3133+
server.tool(
3134+
"publishImage",
3135+
`Publishes text as image format, and ingests into Graphlit knowledge base.
3136+
Accepts a name for the content object.
3137+
Also, accepts a prompt for image generation. For example, 'Create a cartoon image of a raccoon, saying "I Love Graphlit"'.
3138+
You *must* retrieve the content resource to get the downloadable image URL for this published image.
3139+
Executes *synchronously* and returns the content identifier.`,
3140+
{
3141+
name: z.string().describe("Name for the content object."),
3142+
prompt: z.string().describe("Prompt for image generation."),
3143+
},
3144+
async ({ name, prompt }) => {
3145+
const client = new Graphlit();
3146+
3147+
const type = ContentPublishingServiceTypes.OpenAiImage;
3148+
const format = ContentPublishingFormats.Png;
3149+
const model = OpenAiImageModels.GptImage_1;
3150+
3151+
try {
3152+
const response = await client.publishText(prompt, TextTypes.Plain, { type: type, format: format, openAIImage: { model: model } }, name, undefined, true);
3153+
3154+
return {
3155+
content: [{
3156+
type: "text",
3157+
text: JSON.stringify({ id: response.publishText?.id }, null, 2)
3158+
}]
3159+
};
3160+
3161+
} catch (err: unknown) {
3162+
const error = err as Error;
3163+
return {
3164+
content: [{
3165+
type: "text",
3166+
text: `Error: ${error.message}`
3167+
}],
3168+
isError: true
3169+
};
3170+
}
3171+
}
3172+
);
3173+
31323174
server.tool(
31333175
"sendWebHookNotification",
31343176
`Sends a webhook notification to the provided URL.
31353177
Accepts the webhook URL.
31363178
Also accepts the text to be sent with the webhook, and an optional text type (Plain, Markdown, Html). Defaults to Markdown text type.
31373179
Returns true if the notification was successfully sent, or false otherwise.`,
31383180
{
3139-
url: z.string(),
3140-
text: z.string(),
3141-
textType: z.nativeEnum(TextTypes).optional().default(TextTypes.Markdown),
3181+
url: z.string().describe("Webhook URL."),
3182+
text: z.string().describe("Text to send."),
3183+
textType: z.nativeEnum(TextTypes).optional().default(TextTypes.Markdown).describe("Text type (Plain, Markdown, Html). Defaults to Markdown."),
31423184
},
31433185
async ({ text, textType, url }) => {
31443186
const client = new Graphlit();
@@ -3175,9 +3217,9 @@ export function registerTools(server: McpServer) {
31753217
Requires environment variable to be configured: SLACK_BOT_TOKEN.
31763218
Returns true if the notification was successfully sent, or false otherwise.`,
31773219
{
3178-
channelName: z.string(),
3179-
text: z.string(),
3180-
textType: z.nativeEnum(TextTypes).optional().default(TextTypes.Markdown),
3220+
channelName: z.string().describe("Slack channel name."),
3221+
text: z.string().describe("Text to send."),
3222+
textType: z.nativeEnum(TextTypes).optional().default(TextTypes.Markdown).describe("Text type (Plain, Markdown, Html). Defaults to Markdown."),
31813223
},
31823224
async ({ text, textType, channelName }) => {
31833225
const botToken = process.env.SLACK_BOT_TOKEN;
@@ -3220,7 +3262,7 @@ export function registerTools(server: McpServer) {
32203262
Requires environment variables to be configured: TWITTER_CONSUMER_API_KEY, TWITTER_CONSUMER_API_SECRET, TWITTER_ACCESS_TOKEN_KEY, TWITTER_ACCESS_TOKEN_SECRET.
32213263
Returns true if the notification was successfully sent, or false otherwise.`,
32223264
{
3223-
text: z.string()
3265+
text: z.string().describe("Text to send."),
32243266
},
32253267
async ({ text }) => {
32263268
const consumerKey = process.env.TWITTER_CONSUMER_API_KEY;
@@ -3287,10 +3329,10 @@ export function registerTools(server: McpServer) {
32873329
Requires environment variable to be configured: FROM_EMAIL_ADDRESS.
32883330
Returns true if the notification was successfully sent, or false otherwise.`,
32893331
{
3290-
subject: z.string(),
3291-
to: z.array(z.string()),
3292-
text: z.string(),
3293-
textType: z.nativeEnum(TextTypes).optional().default(TextTypes.Markdown),
3332+
subject: z.string().describe("Email subject."),
3333+
to: z.array(z.string()).describe("Email address(es) to send the notification to."),
3334+
text: z.string().describe("Text to send."),
3335+
textType: z.nativeEnum(TextTypes).optional().default(TextTypes.Markdown).describe("Text type (Plain, Markdown, Html). Defaults to Markdown."),
32943336
},
32953337
async ({ text, textType, subject, to }) => {
32963338
const from = process.env.FROM_EMAIL_ADDRESS;

0 commit comments

Comments
 (0)