最後のシリーズのカバーにすみません、すみません。
MCPはどこにでもあり、良い理由で、それはアプリの進化の次のステップです。
どのアプリにもアクセスせずに1つのチャットからすべてを使用できること。Postizチャットからすべてのソーシャル投稿をスケジュール! だから、私はPostizのコードを掘り起こし、それに追加しました!
MCP レポジトリはちょっと変です。
各MCPには、LLMsが私たちのシステムと話すために使用する方法である輸送があります。
There are two primary methods at the momentStdio は、基本的にコマンドラインであり、SSE です。
彼らがSSEを選んだ理由を本当に理解していない - 基本的に、決して終わらない長いリクエストであり、クライアントにイベントをストリーミングします。
この方法の問題は、サーバーに情報を送信するには、別のメールリクエストを送信する必要があるということです(SSEは一方的なコミュニケーションであるため)、つまり、状態を保持しなければなりません。
彼らの例では、アプリのメモリに状態を保管し、何を推測しますか? ユーザーが接続を切ると、その状態が削除されないため、多くのメモリ漏洩に文句を言います。
WebSockets を使用します. 彼らは組み込みの睡眠モードを持っており、それを維持する必要はありません。
掘り下げ ↓↓
Anthropic TypeScript SDK を掘り下げて驚いたわけではありませんが、生産に使われていないものが多く、例えば「リソース」です。 世界中ですべてを記憶に保つことを要求する方法は、起こるのを待っている災害です。
また、認証を実装し、ユーザーを文脈から引き出すことは難しいので、彼らの詳細を得ることができます。
Postiz は NestJS で構築されており、SSE ルートを使用すると、コネクタが切断されると、すべてをメモリから削除することができます。
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 {};
}
}
トップページ > ️
これは、あなたがNestJS/Laravel/SpringのようなOOPフレームワークの大ファンである場合にあなたのためにあります. I created a cool decorator to create tools like API "endpoints."
@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}`,
},
];
}
すべてのコードはここでPostizで見つけることができます:https://github.com/gitroomhq/postiz-app/tree/main/libraries/nestjs-libraries/src/mcp
そしてこちら:https://github.com/githroomhq/postiz-app/tree/main/apps/backend/src/mcp
LLMを強制する ↓↓
LLMが私たちのものにアクセスする前に異なることを行うように強制する組み込みのオプションを持つことは良いでしょう。
僕は興味深い問題に直面したが、Cursorが僕のための投稿をスケジュールするように言ったとき、それは2024年にスケジュールしようと試みた。
いくつかの config 詳細を伝える必要がありましたので、私はPOSTIZ_CONFIGURATION_PRERUN
希望は、LLMは常に物事をする前にそれを呼ぶでしょう。
しかし、それはそれを何度も無視した(典型的な)ので、私は創造的でなければならなかった。POSTIZ_SCHEDULE_POST
新しい不動産を追加しました。configId
config ツールの名前を変更するPOSTIZ_GET_CONFIG_ID.
Config の出力は:id: ${makeId(10)} Today date is ${dayjs.utc().format()}
それはLLMが常にそれを前に呼ぶことを強要し、日付が定められました! :)
それは今からUTCの日付を送ってくれることを知っていたので、私にとってはさらに良いことでした。
使用ケース
私は、それが複数のツールセットと組み合わせた場合、例えば、最もよく機能すると思います。
- ♪
- それをCursorに接続し、今日のあなたの仕事に関する投稿をスケジュールするようにしてください。 ♪
- Notion に接続し、ソーシャルメディアでチームの最新の仕事をスケジュールするようにしてください - Composio MCPs をチェックしてください。 ♪
- CopilotKit を搭載したすべての SaaS に接続し、アプリケーションに基づいて投稿をスケジュールします。 ♪
ポストMCP
ポスト最も強力なオープンソースのソーシャルメディアスケジュールツールであり、今ではMCPを提供する唯一のスケジュールツールです(ネイティブに、Zapierやそのようなものは使用していません)。
新しい MCP を使用すると、Cursor/Windsurf および Anthropic クライアントからすべての投稿をスケジュールできます。
もちろん100%無料です:)
気に入ったなら、星を忘れないでください ⭐️HTTPS://github.com/gitroomhq/postiz-app をダウンロード