CoursesAI-powered Sanity developmentAutomatically generate content
AI-powered Sanity development

Automatically generate content

The Sanity MCP server is going to do the heavy lifting of creating our initial content.
Log in to mark your progress for each Lesson and Task

Sanity Studio is the ultimate workspace to create and edit individual pieces of content. However, if we want to get a good feel for how our studio looks with content in it, and we want to have something to query in our front end later, we're going to need a lot more than a few blog posts.

This is why we installed the Sanity MCP server. It is able to not only query content and interact with the project, it can write data in huge volume with an understanding of your Sanity Studio schema.

You've already set up and confirmed the installation of the MCP server, but just to be sure, you can write a quick prompt now to confirm the LLM has access to the tools.

Open the Chat Pane and prompt the LLM to confirm it has access to the Sanity MCP server.
Do you have access to the Sanity MCP server? What can you tell me about the project currently?
The MCP server relies on a deployed version of your Sanity Studio schema, which this course has not yet prompted you to do. Your LLM might prompt you to do this, or it may just do it itself.

Hopefully you now have confirmation that the Sanity MCP server is operational and your LLM understands the project.

Prompt the LLM to create a document
Please just create one document first, one that represents the Sun in our solar system.

Find the document that was created and verify that you're happy with the results.

This is a good opportunity to double-check that the schema types that were created in the previous lesson are actually suitable for the content being created in this lesson.

For example, my content schema does not contain a type of "star," so it has described the sun as a "planet."

It has also decided to store mass in kilograms, which is going to require numbers larger than it makes sense to store.

With all the context that we have given our LLM, it should be smart enough to be able to make changes to the schema, redeploy the schema, and update the document using the MCP server.

The following prompt is specific to the schema type in my project, you may need to adjust it to suit your results:

1. Update the schema for this document type to include "star" as an option.
2. You attempted to write "mass" as a string, but the schema type was setup for kilograms. Modify the schema for this document type to use a more suitable measure than kilograms.
Update the schema types, deploy the schema, and update the document that you have just created.

Once you've modified your schema and content into a shape you're happier with, it's time to prompt for the rest.

Prompt the LLM to create documents for the planets and moons
Perfect, can we please create documents for the planets and moons of the solar system

Your Studio should now have many documents filled with rich information. This is perfect for creating a front-end.

You have 3 uncompleted tasks in this lesson
0 of 3