😉 MCPs ni kila mahali na kwa sababu nzuri. Ni hatua inayofuata katika maendeleo ya programu.
Being able to use everything from a single chat without accessing any app. It feels native for Postiz to schedule all your social posts from the chat! So, I started to dig into the Postiz code and added to it!
Postiz
The MCP Repository ni kidogo ya ajabu
Kila MCP ina usafiri, ambayo ni njia LLMs kutumia kuzungumza na mfumo wetu.
Kuna mbinu mbili za msingi kwa wakati huu: Stdio, ambayo ni msingi wa mstari wa amri, na SSE.
Kuna mbinu mbili za msingi kwa wakati huu
Sijui kwa nini walichagua SSE - ni msingi wa maombi ya muda mrefu ambayo haina mwisho na huchapisha matukio kwa mteja.
Kwa mfano wao, wanahifadhi hali katika kumbukumbu ya programu, na unadhani nini? Wengi wanatoa malalamiko juu ya upungufu wa kumbukumbu kwa sababu hali haifai wakati mtumiaji huacha kuunganisha.
Ninaitumia WebSockets. Wawili hao wana hali ya kupumzika, na huna haja ya kudumisha hali kwa ajili yake.
kwa hrsKupanda katika
Nilijikuta katika Anthropic typcript SDK na sikuwa na kushangaza. Inaonekana mbaya. Vitu vingi si kutumika katika uzalishaji, kama vile "Vyombo." Njia wanahitaji wewe kuweka kila kitu duniani katika kumbukumbu ni maafa kusubiri kutokea.
Pia, ni vigumu kutekeleza utambulisho na kupata mtumiaji kutoka mazingira ili tuweze kupata maelezo yao.
Nilianzisha "Usafiri" wangu mwenyewe kwa kutumia watazamaji wa rxjs - ni furaha. Postiz imejengwa na NestJS, hivyo wakati unatumia njia ya SSE, inamalizia watazamaji mara moja anakuunganisha, kuruhusu kuondoa kila kitu kutoka kwa kumbukumbu.
import EventEmitter kutoka 'events'; import {finalize, fromEvent, startWith } kutoka 'rxjs'; @Injectable() export class McpService { static event = new EventEmitter(); constructor( private _mainMcp: MainMcp ) { } async runServer(apiKey: string, organization: string) { const server(company, this._mainMcp).server(); const transport = new McpTransport(company); const observer = fromEvent(McpService.event), `transport-${Mcp.event, `transport_transport_##############################import EventEmitter from 'events';
import { finalize, fromEvent, startWith } from 'rxjs';
@Injectable()
export class McpService {
static event = new EventEmitter();
constructor(
private _mainMcp: MainMcp
) {
}
async runServer(apiKey: string, organization: string) {
const server = McpSettings.load(organization, this._mainMcp).server();
const transport = new McpTransport(organization);
const observer = fromEvent(
McpService.event,
`organization-${organization}`
).pipe(
startWith({
type: 'endpoint',
data: process.env.NEXT_PUBLIC_BACKEND_URL + '/mcp/' + apiKey + '/messages',
}),
finalize(() => {
transport.close();
})
);
console.log('MCP transport started');
await server.connect(transport);
return observer;
}
async processPostBody(organization: string, body: object) {
const server = McpSettings.load(organization, this._mainMcp).server();
const message = JSONRPCMessageSchema.parse(body);
const transport = new McpTransport(organization);
await server.connect(transport);
transport.handlePostMessage(message);
return {};
}
}
Mfumo wa Mifumo ya Mifumo ya Mifumo ya Mifumo ️
Hii ni kwa ajili yenu ikiwa wewe ni mtazamaji mkubwa wa mifumo ya OOP kama NestJS / Laravel / Spring. Niliunda decorator ya kushangaza ili kuunda zana kama API "endpoints."
Nafasi hii inatumika kwa ajili ya kukabiliana na matatizo yanayowakabiliwa na maambukizi ya maambukizi ya maambukizi ya maambukizi ya maambukizi ya maambukizi ya maambukizi ya maambukizi ya maambukizi ya maambukizi. @McpTool({ toolName: 'POSTIZ_GET_CONFIG_ID' })
async preRun() {
return [
{
type: 'text',
text: `id: ${makeId(10)} Today date is ${dayjs.utc().format()}`,
},
];
}
@McpTool({ toolName: 'POSTIZ_PROVIDERS_LIST' })
async listOfProviders(organization: string) {
const list = (
await this._integrationService.getIntegrationsList(organization)
).map((org) => ({
id: org.id,
name: org.name,
identifier: org.providerIdentifier,
picture: org.picture,
disabled: org.disabled,
profile: org.profile,
customer: org.customer
? {
id: org.customer.id,
name: org.customer.name,
}
: undefined,
}));
return [{ type: 'text', text: JSON.stringify(list) }];
}
@McpTool({
toolName: 'POSTIZ_SCHEDULE_POST',
zod: {
type: eenum(['draft', 'scheduled']),
configId: string(),
generatePictures: boolean(),
date: string().describe('UTC TIME'),
providerId: string().describe('Use POSTIZ_PROVIDERS_LIST to get the id'),
posts: array(object({ text: string(), images: array(string()) })),
},
})
async schedulePost(
organization: string,
obj: {
type: 'draft' | 'schedule';
generatePictures: boolean;
date: string;
providerId: string;
posts: { text: string }[];
}
) {
const create = await this._postsService.createPost(organization, {
date: obj.date,
type: obj.type,
tags: [],
posts: [
{
group: makeId(10),
value: await Promise.all(
obj.posts.map(async (post) => ({
content: post.text,
id: makeId(10),
image: !obj.generatePictures
? []
: [
{
id: makeId(10),
path: await this._openAiService.generateImage(
post.text,
true
),
},
],
}))
),
// @ts-ignore
settings: {},
integration: {
id: obj.providerId,
},
},
],
});
return [
{
type: 'text',
text: `Post created successfully, check it here: ${process.env.FRONTEND_URL}/p/${create[0].postId}`,
},
];
}
All the code can be found in Postiz here: https://github.com/gitroomhq/postiz-app/tree/main/libraries/nestjs-libraries/src/mcp
https://github.com/gitroomhq/postiz-app/tree/main/libraries/nestjs-libraries/src/mcp
And here: https://github.com/gitroomhq/postiz-app/tree/main/apps/backend/src/mcp
https://github.com/gitroomhq/postiz-app/tree/main/apps/backend/src/mcpkwa hrsKutoa LLM kufanya kitu 💪🏻
Itakuwa nzuri kuwa na chaguo la kujengwa ili kulazimisha LLM kufanya mambo tofauti kabla ya kufikia mambo yetu.
Kila wakati nilimwambia Cursor kupanga chapisho kwangu, alijaribu kupanga kwa 2024.
Nilipaswa kupitisha maelezo ya config, hivyo niliunda chombo cha POSTIZ_CONFIGURATION_PRERUN
.POSTIZ_CONFIGURATION_PRERUN
Lakini ilikuwa imechukuliwa mara nyingi (kwa kawaida), hivyo nililazimika kuwa na ubunifu. Katika POSTIZ_SCHEDULE_POST
, niliongeza sifa mpya inayoitwa configId
na kubadili jina la chombo cha config kwa POSTIZ_GET_CONFIG_ID.
Matokeo ya config ni:id: ${makeId(10)} Siku ya leo ni ${day.jsutc().format()}
POSTIZ_SCHEDULE_POST
configId
POSTIZ_GET_CONFIG_ID.
id: ${makeId(10)} Today date is ${dayjs.utc().format()}
Ili kulazimisha LLM daima kuita kabla, na tarehe ilikuwa imara! :)
Ilikuwa hata bora kwangu kwa sababu nilijua itakuwa kutuma mimi UTC tarehe kutoka sasa.
kwa hrsMipango ya matumizi
Nadhani inafanya kazi bora wakati ni pamoja na seti nyingi za zana, kwa mfano:
- Connect it to Cursor and ask it to schedule a post about your work today.
- Connect it to Notion and ask to schedule all the team's latest work on social media - check out Composio MCPs.
- Connect it to any SaaS that has CopilotKit and schedule posts based on the app.
Kujumuisha kwa Cursor na kuuliza kupanga chapisho kuhusu kazi yako leo. Connect it to Notion and ask to schedule all the team's latest work on social media - check out Composio MCPs. Composio MCPsConnect it to any SaaS that has CopilotKit and schedule posts based on the app. CopilotKitkwa hrsPostiz MCP
Postiz is the most robust open-source social media scheduling tool - and now the only scheduler that offers MCP (natively, not with Zapier or something like that)
Postiz
Kwa MCP mpya, unaweza kupanga machapisho yako yote kutoka kwa wateja wako wa Cursor / Windsurf na Anthropic.
Kila kitu ni 100% ya bure, bila shaka. :)
If you like it, please don't forget to star us ⭐️https://github.com/gitroomhq/postiz-app
https://github.com/gitroomhq/postiz-app
kwa BR