Lesson 26 of 30, Module 4: Ship It. It publishes to Substack, runs on the web, and anyone can install it.
What you can do after this lesson
A tool's happy sentence in a chat only tells you what it meant to do. To know what it did, ask the system of record directly, with a script that checks state (published is false, the draft is gone) and cleans up after itself. And let the tool carry the work up to the irreversible step, then stop and leave that step to a human.
The problem we inherited
The draft is finished in Drive and still goes nowhere. You copy it into Substack by hand, which is exactly where you came in.
Code in this lesson
Every block the lesson shows on screen, in the order it appears.
Use scribe to fix the typo in draft.md.
Use scribe to send draft.md to Substack.
export SCRIBE_FOLDER_ID="paste your folder id here"
export SCRIBE_KEY="key.json"
export SCRIBE_SUBSTACK="your-publication-name"
export SCRIBE_SUBSTACK_COOKIE="paste the substack.sid value here"
python3 prove_substack.py
Downloads
- Module 4 checkpoint (scribe-checkpoint-m4.zip): working code as the module leaves it, so a broken session costs you nothing
- The course GitHub repo: every checkpoint, the README and the full lesson list
Lesson transcript
Drive to Substack, nothing copied
Today a draft goes from my Drive to my Substack, and I never copy a thing. The last click is mine, and it is the only thing I do by hand.
Hello, and welcome to lesson 26 of the MCP Masterclass. Last lesson you gave Scribe a second service in the same 5 steps. Today we run the whole chain, end to end, and then we prove it with a script. And we start with our map, as always.
14 lit boxes, and nothing new lights up today. Today we use what is already there, all of it, in 1 go.
The chain in 5 steps
Well, here is the chain, before we run it. Read the draft. Fix it, which means the guard asks. Send it to Substack. Open the link. Press Publish. 3 tools from 3 modules, and 1 click from you.
Running it in Claude Desktop
The draft is draft.md, and it still has the typo in it. Ths line, with the i missing.
Open Claude Desktop, and ask for the fix first.
Use scribe to fix the typo in draft.md.
On screen: Claude Desktop calls edit_doc. The call stops, and Claude asks in the chat whether to change 'Ths line' to 'This line' in draft.md. The person answers yes. Claude calls edit_doc again with said_yes true. "Changed 1 spot(s) in draft.md."
Scribe stops and asks, the way it has since lesson 17. Say yes, and the draft changes. Nothing about that moved when we added Substack, and I want you to notice that. The guard did not know a second service arrived.
Now the new part.
Use scribe to send draft.md to Substack.
On screen: Claude calls publish_draft with name draft.md. The result: "Draft made from draft.md. Open it, read it, then publish it yourself:" and a link to genaiunplugged.substack.com/publish/post/ followed by a number.
Claude reads the docstring, picks publish draft, and sends the name. And Scribe comes back with 2 lines. Draft made from draft.md. Open it, read it, then publish it yourself. And a link.
Click the link.
On screen: the Substack editor opens. The title reads "My first draft". The body holds the fixed line, "This is a test. This line has a typo in it." Hold 3 seconds.
That is the Substack editor, and that is my draft. The title came from the first line of the file. The body is the fixed text, not the typo, because Scribe read the draft after the edit, not before.
I did not copy anything. I did not paste anything. The last manual step from lesson 24 is gone.
Why Scribe stops at the Publish button
And now the button. Publish is right there, at the top. It is yours, and I am not going to press it on camera, because this draft is a test and my readers do not need it.
On screen: the mouse rests over the Publish button and does not click. Hold 2 seconds.
But that is the point of the whole lesson. Scribe carried the draft all the way to the button, and then it stopped. The question in lesson 17 was, may I write this file. The question here is, may I email everyone you know. Scribe does not get to answer that one. You do.
Proving it with a script: 4 checks
Now, you know by now that a happy sentence in a chat has only told you what the tool meant to do. So we prove it, from a script, the way we proved the guard in lesson 18.
The script is in your module 4 checkpoint. It is called prove substack dot pie. Copy it into your scribe folder, next to scribe_server.py, and run it.
export SCRIBE_FOLDER_ID="paste your folder id here"
export SCRIBE_KEY="key.json"
export SCRIBE_SUBSTACK="your-publication-name"
export SCRIBE_SUBSTACK_COOKIE="paste the substack.sid value here"
python3 prove_substack.py
Windows users, your lines are in the checkpoint notes. And if you have no Substack, leave the last 2 lines out. The script runs the read half and tells you it skipped the rest.
Check number 1. The public read, with no login.
On screen: prove_substack.py, check 1. The server starts with no cookie, latest_posts returns 2 dated posts with links. PASS.
The script starts your server with the cookie taken away, and asks for the 2 newest posts on a Substack. Two dated lines come back. That half needs nobody's permission.
Check number 2. A draft is made from draft.md.
On screen: check 2. publish_draft returns "Draft made from draft.md. Open it, read it, then publish it yourself:" and a link.
Now the server starts with your cookie, and the script sends your draft. Same 2 lines, same kind of link. But the script does not trust the sentence. It asks Substack directly.
Check number 3. It is a draft, and nothing was published.
On screen: check 3. The script reads the draft back from Substack: title "My first draft", published: False. PASS.
The script asks Substack for that draft by its number, and Substack hands back the title, and 1 field that says published, false. Nobody was emailed. That is the proof that the word draft in the docstring is true.
Check number 4. The script deletes its own draft again.
On screen: check 4. "deleted: 200, then: 404". Then the verdict, 4 PASS, "RESULT: Scribe delivers."
A proof script should leave your account the way it found it, the way break_it.py left your Drive alone. So it deletes the draft it made, and then asks for it once more. 404 means Substack has never heard of it. Gone.
4 passes. Scribe delivers.
Why the script beats the chat
And here is why the script matters more than the chat. The chat showed you 1 draft that looked right. The script read the published field. A tool that quietly published would pass the chat and fail check 3. That is the check I would run after every change you make to publish draft.
What does not come through yet
One honest note before we close. Open the draft the script made, if you catch it before the delete, or the one from the chat. Headings and paragraphs are there. Bold, links and lists came through as plain words, as I said last lesson. For a draft that is fine. For a long post you will spend a minute in the editor, and that minute used to be the whole job.
Where the map stands, and what is next
So where does our map stand at the end of this lesson?
Still 14 boxes lit. But now the whole chain has run. Drive, the guard, Substack, and 1 click from you at the end.
Next lesson Scribe leaves the laptop. We talk about the pipe you have been using since lesson 6, and the web address that replaces it with 1 call.
Bye now, and I will see you in the next lesson.