Node & MCP
Leon Noel
"They ask me how I do it
I just bite off more then I can chew
And then I chew it"

Agenda
-
Questions?
-
Let's Talk - Questions
-
Review - CRUD
-
Learn - MCP
-
Learn - Build A Simple MCP Server
-
Homework - Build your own Server
Questions
About last class or life

She A Baddie She Know She A 10

Backend!

NODE.js BABY

Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine.

Engine Vs. Compiler
And just like the browser's Web APIs Node come with a bunch of stuff
Built in Modules
(libraries or collections of functions)
HTTP (network access)
FS (file system access)
Access to millions of packages via NPM
(groupings of one or more custom modules)
Not Web APIs, but C/C++ APIs

sorry, don't remember the source
Let's Code
Simple Node Server

Just HTTP & FS
const server = http.createServer((req, res) => {
const page = url.parse(req.url).pathname;
const params = querystring.parse(url.parse(req.url).query);
console.log(page);
if (page == '/') {
fs.readFile('index.html', function(err, data) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(data);
res.end();
});
}
else if (page == '/otherpage') {
fs.readFile('otherpage.html', function(err, data) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(data);
res.end();
});
}
else if (page == '/otherotherpage') {
fs.readFile('otherotherpage.html', function(err, data) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(data);
res.end();
});
}
else if (page == '/api') {
if('student' in params){
if(params['student']== 'leon'){
res.writeHead(200, {'Content-Type': 'application/json'});
const objToJson = {
name: "leon",
status: "Boss Man",
currentOccupation: "Baller"
}
res.end(JSON.stringify(objToJson));
}//student = leon
else if(params['student'] != 'leon'){
res.writeHead(200, {'Content-Type': 'application/json'});
const objToJson = {
name: "unknown",
status: "unknown",
currentOccupation: "unknown"
}
res.end(JSON.stringify(objToJson));
}//student != leon
}//student if
}//else if
else if (page == '/css/style.css'){
fs.readFile('css/style.css', function(err, data) {
res.write(data);
res.end();
});
}else if (page == '/js/main.js'){
fs.readFile('js/main.js', function(err, data) {
res.writeHead(200, {'Content-Type': 'text/javascript'});
res.write(data);
res.end();
});
}else{
figlet('404!!', function(err, data) {
if (err) {
console.log('Something went wrong...');
console.dir(err);
return;
}
res.write(data);
res.end();
});
}
});
server.listen(8000);
How could we clean this up?
Express
Express
Fast, unopinionated, minimalist web framework for Node.js
With a myriad of HTTP utility methods and middleware at your disposal, creating a robust API is quick and easy.

How Does The Internet Work

CRUD
Create (post) - Make something
Read (get) - Get Something
Update (put) - Change something
Delete (delete) - Remove something
Client (Laptop)
Browser
URL
Server
Disk
API Code
Files
Mongo
Database
Collection
Collection
document
document
document
document
app.get('/')
app.post('/form')
app.put('/info')
app.delete('/info')
/views
/public
index.ejs
main.js
style.css
Fonts
Images
What are some Create (post) requests?
What are some Read (get) requests?
What are some Update (put) requests?
What are some Delete (delete) requests?
Client (Laptop)
Browser
URL
Server
Disk
API Code
Files
Mongo
Database
Collection
Collection
document
document
document
document
app.get('/')
app.post('/form')
app.put('/info')
app.delete('/info')
/views
/public
index.ejs
main.js
style.css
Fonts
Images
What is MCP?
Model Context Protocol
Model
Machine Learning "System" that takes inputs, processes them, and produces outputs based on patterns it has learned from data



Trained on billions of words and now can predict the most likely next set of words based on what it has learned
Context
The information or environment that makes everything make sense
Past Conversation
Who, what, where
What you are doing
What is the capital of Vermont?
What is the weather like there?
With context: COLD
Without context: Huh?
Protocol
Set of rules and/or procedures for how something should be done

Get
Post
Put
Delete






Tools
Resources
Resource
Think Get
Tool
Think Post
Questions? !ask

Let's Code
Simple MCP Server

Homework

RC - MCP
By Leon Noel
RC - MCP
- 162