Estrutura de projeto para um servidor
Organize os arquivos para que seu servidor possa crescer facilmente.
Estrutura de projeto para um servidor é uma aula grátis de MCP Academy no CoddyKit. Esta é a aula 4 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de MCP Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de MCP Academy inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
Structure Sets You Up
A small server fits in one file, but a good layout lets it grow without becoming a mess. A little planning now saves real pain later. 🗂️
Start with One File
Most servers begin life as a single server.py. It holds your FastMCP instance plus a tool or two, which is plenty to get running.
pyproject.toml Is the Map
At the root sits pyproject.toml, declaring your project name and its dependencies. uv reads it to know exactly what to install.
The Lockfile Stays Put
Right beside it lives uv.lock, the pinned record of every resolved version. Commit it so teammates reproduce your exact setup.
Keep .venv Out of Git
The .venv folder is generated, not source code. Add it to .gitignore so you never commit a heavy, machine-specific environment.
.venv/
__pycache__/Group by Primitive
As you grow, split code by what it does. Putting tools, resources, and prompts in separate modules keeps each file focused and readable.
A Typical Tree
A growing server often looks like this: a server entry point next to a folder for each kind of capability. Clear folders mean fast navigation. 🌳
my-server/
server.py
tools/
resources/
prompts/One Entry Point
Keep a single entry point that creates the FastMCP instance and registers everything. Clients only ever need to launch this one file.
Import, Don't Inline
Define tools in their own modules, then import and register them in the entry file. Your server.py stays short and easy to scan.
from tools.math import register_math
register_math(mcp)Add a README
A short README telling others how to install and run your server makes it shareable. Future-you will thank present-you for it.
Keep Secrets Outside
Never hardcode keys in your code. Read them from environment variables and keep a sample .env so config stays safe and portable. 🔐
Quick Check
You're deciding what to commit to version control.
A Layout That Scales
You learned to start in one file, keep pyproject.toml and the lockfile tracked, ignore .venv, and split by primitive. Your server can grow cleanly. ✅
Perguntas Frequentes
A aula “Estrutura de projeto para um servidor” é grátis?
Sim — o texto completo de “Estrutura de projeto para um servidor” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de MCP Academy, atualize para CoddyKit PRO. O curso de MCP Academy inclui 4 aulas no total.
O que vou aprender em “Estrutura de projeto para um servidor”?
Organize os arquivos para que seu servidor possa crescer facilmente. Você pratica MCP Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar MCP Academy?
Nenhuma experiência prévia é necessária. MCP Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 4 de 4.
Quanto tempo leva a aula “Estrutura de projeto para um servidor”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de MCP Academy?
Sim. Cada aula de MCP Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- Instalar Python e uv
- Adicionar o SDK Python do MCP
- Conheça a CLI mcp
- Estrutura de projeto para um servidor